@@ -11,24 +11,24 @@ discard block |
||
11 | 11 | |
12 | 12 | trait ToArrayTrait |
13 | 13 | { |
14 | - private function isOnly(ReflectionProperty $property, array $optionsToArray): bool |
|
14 | + private function isOnly (ReflectionProperty $property, array $optionsToArray): bool |
|
15 | 15 | { |
16 | - if (!isset($optionsToArray['only']) && !isset($optionsToArray['except'])) { |
|
16 | + if (!isset($optionsToArray[ 'only' ]) && !isset($optionsToArray[ 'except' ])) { |
|
17 | 17 | return true; |
18 | 18 | } |
19 | 19 | |
20 | - if (isset($optionsToArray['only'])) { |
|
21 | - if (in_array($property->getName(), $optionsToArray['only'])) { |
|
20 | + if (isset($optionsToArray[ 'only' ])) { |
|
21 | + if (in_array($property->getName(), $optionsToArray[ 'only' ])) { |
|
22 | 22 | return true; |
23 | 23 | } |
24 | - } else if (isset($optionsToArray['except']) && !in_array($property->getName(), $optionsToArray['except'])) { |
|
24 | + } else if (isset($optionsToArray[ 'except' ]) && !in_array($property->getName(), $optionsToArray[ 'except' ])) { |
|
25 | 25 | return true; |
26 | 26 | } |
27 | 27 | |
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
31 | - private function getPropertiesFillable(): array |
|
31 | + private function getPropertiesFillable (): array |
|
32 | 32 | { |
33 | 33 | $allProperties = $this->getRepository() |
34 | 34 | ->getClassMetadata() |
@@ -44,14 +44,14 @@ discard block |
||
44 | 44 | }); |
45 | 45 | } |
46 | 46 | |
47 | - public function toArray(array $options = []): array |
|
47 | + public function toArray (array $options = [ ]): array |
|
48 | 48 | { |
49 | 49 | $classMetadata = $this->getRepository() |
50 | 50 | ->getClassMetadata(); |
51 | 51 | |
52 | 52 | $propertiesFillable = $this->getPropertiesFillable(); |
53 | 53 | |
54 | - $array = []; |
|
54 | + $array = [ ]; |
|
55 | 55 | |
56 | 56 | foreach ($propertiesFillable as $property) { |
57 | 57 | if ($this->isOnly($property, $options)) { |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $dateFormat = 'Y-m-d'; |
65 | 65 | |
66 | 66 | if ($metaDataKey) { |
67 | - switch ($metaDataKey['type']) { |
|
67 | + switch ($metaDataKey[ 'type' ]) { |
|
68 | 68 | case 'datetime': |
69 | 69 | $dateFormat = 'Y-m-d H:i:s'; |
70 | 70 | break; |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - $array[$key] = $this->$key->format($dateFormat); |
|
79 | + $array[ $key ] = $this->$key->format($dateFormat); |
|
80 | 80 | } |
81 | 81 | } elseif ($this->$key instanceof ArrayCollection || $this->$key instanceof PersistentCollection) { |
82 | - $array[$key] = array_map(function ($item) { |
|
82 | + $array[ $key ] = array_map(function ($item) { |
|
83 | 83 | return $item->getId(); |
84 | 84 | }, $this->$key->getValues()); |
85 | 85 | } else { |
86 | 86 | if (method_exists($this->$key, 'getId')) { |
87 | - $array[$key] = $this->$key->getId(); |
|
87 | + $array[ $key ] = $this->$key->getId(); |
|
88 | 88 | } else { |
89 | - $array[$key] = $this->$key; |
|
89 | + $array[ $key ] = $this->$key; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | } else { |
93 | - if (in_array($metaDataKey['type'], ['decimal', 'float'])) { |
|
94 | - $array[$key] = (float) $this->$key; |
|
93 | + if (in_array($metaDataKey[ 'type' ], [ 'decimal', 'float' ])) { |
|
94 | + $array[ $key ] = (float) $this->$key; |
|
95 | 95 | } else { |
96 | - $array[$key] = $this->$key; |
|
96 | + $array[ $key ] = $this->$key; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -48,27 +48,27 @@ discard block |
||
48 | 48 | */ |
49 | 49 | protected $deletedAt; |
50 | 50 | |
51 | - public function getId() |
|
51 | + public function getId () |
|
52 | 52 | { |
53 | 53 | return $this->id; |
54 | 54 | } |
55 | 55 | |
56 | - public function getCreatedAt(): ?DateTime |
|
56 | + public function getCreatedAt (): ?DateTime |
|
57 | 57 | { |
58 | 58 | return $this->createdAt; |
59 | 59 | } |
60 | 60 | |
61 | - public function getUpdatedAt(): ?DateTime |
|
61 | + public function getUpdatedAt (): ?DateTime |
|
62 | 62 | { |
63 | 63 | return $this->createdAt; |
64 | 64 | } |
65 | 65 | |
66 | - public function getDeletedAt(): ?DateTime |
|
66 | + public function getDeletedAt (): ?DateTime |
|
67 | 67 | { |
68 | 68 | return $this->deletedAt; |
69 | 69 | } |
70 | 70 | |
71 | - public function getRepository(): RepositoryContract |
|
71 | + public function getRepository (): RepositoryContract |
|
72 | 72 | { |
73 | 73 | return EntityManager::getRepository(get_class($this)); |
74 | 74 | } |
@@ -76,53 +76,53 @@ discard block |
||
76 | 76 | /** |
77 | 77 | * @ORM\PreRemove |
78 | 78 | */ |
79 | - public function preRemove() |
|
79 | + public function preRemove () |
|
80 | 80 | { |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @ORM\PostRemove |
85 | 85 | */ |
86 | - public function postRemove() |
|
86 | + public function postRemove () |
|
87 | 87 | { |
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @ORM\PrePersist |
92 | 92 | */ |
93 | - public function prePersist() |
|
93 | + public function prePersist () |
|
94 | 94 | { |
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @ORM\PostPersist |
99 | 99 | */ |
100 | - public function postPersist() |
|
100 | + public function postPersist () |
|
101 | 101 | { |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
105 | 105 | * @ORM\PreUpdate |
106 | 106 | */ |
107 | - public function preUpdate() |
|
107 | + public function preUpdate () |
|
108 | 108 | { |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @ORM\PostUpdate |
113 | 113 | */ |
114 | - public function postUpdate() |
|
114 | + public function postUpdate () |
|
115 | 115 | { |
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
119 | 119 | * @ORM\PreFlush |
120 | 120 | */ |
121 | - public function preFlush() |
|
121 | + public function preFlush () |
|
122 | 122 | { |
123 | 123 | } |
124 | 124 | |
125 | - public function persist(): BdContracts\EntityContract |
|
125 | + public function persist (): BdContracts\EntityContract |
|
126 | 126 | { |
127 | 127 | $this->getRepository() |
128 | 128 | ->getEntityManager() |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | return $this; |
132 | 132 | } |
133 | 133 | |
134 | - public function flush(): BdContracts\EntityContract |
|
134 | + public function flush (): BdContracts\EntityContract |
|
135 | 135 | { |
136 | 136 | $this->getRepository() |
137 | 137 | ->getEntityManager() |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function remove(): BdContracts\EntityContract |
|
143 | + public function remove (): BdContracts\EntityContract |
|
144 | 144 | { |
145 | 145 | $this->getRepository() |
146 | 146 | ->remove($this); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function undelete(): BdContracts\EntityContract |
|
151 | + public function undelete (): BdContracts\EntityContract |
|
152 | 152 | { |
153 | 153 | $this->deletedAt = null; |
154 | 154 |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -return []; |
|
3 | +return [ ]; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @param Schema $schema |
12 | 12 | */ |
13 | - public function up(Schema $schema) |
|
13 | + public function up (Schema $schema) |
|
14 | 14 | { |
15 | 15 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
16 | 16 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | /** |
21 | 21 | * @param Schema $schema |
22 | 22 | */ |
23 | - public function down(Schema $schema) |
|
23 | + public function down (Schema $schema) |
|
24 | 24 | { |
25 | 25 | $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
26 | 26 |