Total Complexity | 5 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class CategoryEntity extends Entity |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | * |
||
19 | * @ORM\Column(type="string", length=255, unique=true, nullable=false) |
||
20 | */ |
||
21 | private $name; |
||
22 | |||
23 | /** |
||
24 | * @param string $id |
||
25 | * @param string $name |
||
26 | */ |
||
27 | private function __construct( |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param Category $category |
||
37 | * @return CategoryEntity |
||
38 | */ |
||
39 | public static function fromCategory(Category $category): CategoryEntity |
||
40 | { |
||
41 | return new CategoryEntity( |
||
42 | $category->getId()->toString(), |
||
43 | $category->getName()->toNative() |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return Category |
||
49 | */ |
||
50 | public function toCategory(): Category |
||
51 | { |
||
52 | return new Category( |
||
53 | Uuid::fromString($this->getId()), |
||
54 | new NotEmptyString($this->getName()) |
||
55 | ); |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getName(): string |
||
62 | { |
||
63 | return $this->name; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param string $name |
||
68 | */ |
||
69 | public function setName(string $name): void |
||
72 | } |
||
73 | } |
||
74 |