Skip to content

Commit

Permalink
Update for micro/dto
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksiiBulba committed Jul 6, 2024
1 parent 30894ba commit 9b1628d
Show file tree
Hide file tree
Showing 53 changed files with 130 additions and 381 deletions.
37 changes: 0 additions & 37 deletions ClassDef/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,10 @@

class ClassDefinition
{
/**
* @var string
*/
private string $extends = ClassMetadataHelperInterface::PROPERTY_TYPE_ABSTRACT_CLASS;

/**
* @var string
*/
private string $namespace = '';

/**
* @var string
*/
private string $name = '';

/**
Expand All @@ -52,49 +43,31 @@ class ClassDefinition
*/
private array $comments = [];

/**
* @return string
*/
public function getExtends(): string
{
return $this->extends;
}

/**
* @param string $extends
*/
public function setExtends(string $extends): void
{
$this->extends = $extends;
}

/**
* @return string
*/
public function getNamespace(): string
{
return $this->namespace;
}

/**
* @param string $namespace
*/
public function setNamespace(string $namespace): void
{
$this->namespace = $namespace;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
Expand All @@ -108,11 +81,6 @@ public function getProperties(): iterable
return $this->properties;
}

/**
* @param PropertyDefinition $propertyDefinition
*
* @return $this
*/
public function addProperty(PropertyDefinition $propertyDefinition): self
{
$this->properties[] = $propertyDefinition;
Expand Down Expand Up @@ -145,11 +113,6 @@ public function getComments(): iterable
return $this->comments;
}

/**
* @param string $comment
*
* @return $this
*/
public function addComment(string $comment): self
{
if (!\in_array($comment, $this->comments)) {
Expand Down
28 changes: 4 additions & 24 deletions ClassDef/MethodDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,49 +18,41 @@ class MethodDefinition
private string $visibility = 'public';

private string $name = '';

/**
* @var string[]
*/
private array $typesReturn = [];

/**
* @var PropertyDefinition[]
*/
private array $args = [];

private string $body = '';

/**
* @var string[]
*/
private array $comments = [];

private bool $isStatic = false;

/**
* @return string
*/
public function getVisibility(): string
{
return $this->visibility;
}

/**
* @param string $visibility
*/
public function setVisibility(string $visibility): void
{
$this->visibility = $visibility;
}

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
Expand Down Expand Up @@ -98,17 +90,11 @@ public function setArgs(array $args): void
$this->args = $args;
}

/**
* @return string
*/
public function getBody(): string
{
return $this->body;
}

/**
* @param string $body
*/
public function setBody(string $body): void
{
$this->body = $body;
Expand All @@ -122,17 +108,11 @@ public function getComments(): array
return $this->comments;
}

/**
* @return bool
*/
public function isStatic(): bool
{
return $this->isStatic;
}

/**
* @param bool $isStatic
*/
public function setIsStatic(bool $isStatic): void
{
$this->isStatic = $isStatic;
Expand Down
30 changes: 3 additions & 27 deletions ClassDef/PropertyDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@

class PropertyDefinition
{
private string $name;
private string $name = '';

/**
* @var string[]
*/
private array $comments = [];

/**
* @var string[]
*/
Expand All @@ -32,24 +33,14 @@ class PropertyDefinition
private array $attributes = [];

private bool $isRequired = false;
private bool $isCollection = false;

public function __construct()
{
$this->name = '';
}
private bool $isCollection = false;

/**
* @return string
*/
public function getName(): string
{
return $this->name;
}

/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
Expand Down Expand Up @@ -86,43 +77,28 @@ public function setTypes(array $types): void
$this->types = $types;
}

/**
* @return bool
*/
public function isRequired(): bool
{
return $this->isRequired;
}

/**
* @param bool $isRequired
*/
public function setIsRequired(bool $isRequired): void
{
$this->isRequired = $isRequired;
}

/**
* @return bool
*/
public function isCollection(): bool
{
return $this->isCollection;
}

/**
* @param bool $isCollection
*/
public function setIsCollection(bool $isCollection): void
{
$this->isCollection = $isCollection;
}

/**
* @param string $attributeName
* @param array<string, mixed> $arguments
*
* @return $this
*/
public function addAttribute(string $attributeName, array $arguments): self
{
Expand Down
19 changes: 6 additions & 13 deletions ClassGeneratorFacadeDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@
class ClassGeneratorFacadeDefault extends GeneratorFacade
{
/**
* @param array<string> $filesSchemeCollection
* @param string $outputPath
* @param string $namespaceGeneral
* @param string $classSuffix
* @param LoggerInterface|null $logger
* @param array<string> $filesSchemeCollection
*/
public function __construct(
private array $filesSchemeCollection,
private string $outputPath,
private string $namespaceGeneral = '',
private string $classSuffix = 'Transfer',
private null|LoggerInterface $logger = null
private readonly array $filesSchemeCollection,
private readonly string $outputPath,
private readonly string $namespaceGeneral = '',
private readonly string $classSuffix = 'Transfer',
private readonly ?LoggerInterface $logger = null
) {
parent::__construct($this->createDefaultDependencyInjectionObject());
}

/**
* @return DependencyInjectionInterface
*/
protected function createDefaultDependencyInjectionObject(): DependencyInjectionInterface
{
return new DependencyInjection(
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;

class DependencyInjection implements DependencyInjectionInterface
readonly class DependencyInjection implements DependencyInjectionInterface
{
/**
* @param string[] $filesSchemeCollection
Expand Down
18 changes: 0 additions & 18 deletions DependencyInjectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,15 @@

interface DependencyInjectionInterface
{
/**
* @return LoggerInterface
*/
public function getLogger(): LoggerInterface;

/**
* @return CollectionPreparationInterface
*/
public function createClassPreparationProcessor(): CollectionPreparationInterface;

/**
* @return ClassMetadataHelper
*/
public function createClassMetadataHelper(): ClassMetadataHelper;

/**
* @return WriterInterface
*/
public function createWriter(): WriterInterface;

/**
* @return ReaderInterface
*/
public function createReader(): ReaderInterface;

/**
* @return RendererInterface
*/
public function createRenderer(): RendererInterface;
}
6 changes: 0 additions & 6 deletions DtoFacadeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@

interface DtoFacadeInterface
{
/**
* @return GeneratorFacadeInterface
*/
public function createGenerator(): GeneratorFacadeInterface;

/**
* @return SerializerFacadeInterface
*/
public function createSerializer(): SerializerFacadeInterface;
}
5 changes: 1 addition & 4 deletions Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Micro\Library\DTO\Writer\WriterInterface;
use Psr\Log\LoggerInterface;

class Generator
readonly class Generator
{
public function __construct(
private ReaderInterface $reader,
Expand All @@ -31,9 +31,6 @@ public function __construct(
) {
}

/**
* @return void
*/
public function generate(): void
{
/** @var ClassDefinition $classDef */
Expand Down
5 changes: 1 addition & 4 deletions GeneratorFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@
class GeneratorFacade implements GeneratorFacadeInterface
{
public function __construct(
private DependencyInjectionInterface $dependencyInjection
private readonly DependencyInjectionInterface $dependencyInjection
) {
}

/**
* {@inheritDoc}
*/
public function generate(): void
{
$generator = new Generator(
Expand Down
Loading

0 comments on commit 9b1628d

Please sign in to comment.