@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | public function findRemoved($id, bool $abort = true): ?EntityContract |
69 | 69 | { |
70 | 70 | $entity = $this->findAllRemoved() |
71 | - ->andWhere('id', '=', $id) |
|
72 | - ->getOneResult(); |
|
71 | + ->andWhere('id', '=', $id) |
|
72 | + ->getOneResult(); |
|
73 | 73 | |
74 | 74 | enableSoftDeleteableFilter(); |
75 | 75 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | public function remove(EntityContract $entity): EntityContract |
91 | 91 | { |
92 | 92 | $this->getEntityManager() |
93 | - ->remove($entity); |
|
93 | + ->remove($entity); |
|
94 | 94 | |
95 | 95 | return $entity; |
96 | 96 | } |
@@ -11,27 +11,27 @@ discard block |
||
11 | 11 | |
12 | 12 | abstract class BaseRepository extends EntityRepository implements RepositoryContract |
13 | 13 | { |
14 | - public function getEntityManager(): EntityManager |
|
14 | + public function getEntityManager (): EntityManager |
|
15 | 15 | { |
16 | 16 | return parent::getEntityManager(); |
17 | 17 | } |
18 | 18 | |
19 | - public function getClassMetadata(): ClassMetadata |
|
19 | + public function getClassMetadata (): ClassMetadata |
|
20 | 20 | { |
21 | 21 | return parent::getClassMetadata(); |
22 | 22 | } |
23 | 23 | |
24 | - public function createQueryWorker(): QueryWorkerContract |
|
24 | + public function createQueryWorker (): QueryWorkerContract |
|
25 | 25 | { |
26 | 26 | return new QueryWorker($this); |
27 | 27 | } |
28 | 28 | |
29 | - public function findAll(): QueryWorkerContract |
|
29 | + public function findAll (): QueryWorkerContract |
|
30 | 30 | { |
31 | 31 | return $this->createQueryWorker(); |
32 | 32 | } |
33 | 33 | |
34 | - public function findOneBy(array $criteria, bool $abort = true): ?EntityContract |
|
34 | + public function findOneBy (array $criteria, bool $abort = true): ?EntityContract |
|
35 | 35 | { |
36 | 36 | $findAll = $this->findAll(); |
37 | 37 | |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | return null; |
53 | 53 | } |
54 | 54 | |
55 | - public function find($id, bool $abort = true): ?EntityContract |
|
55 | + public function find ($id, bool $abort = true): ?EntityContract |
|
56 | 56 | { |
57 | - return $this->findOneBy(['id' => $id], $abort); |
|
57 | + return $this->findOneBy([ 'id' => $id ], $abort); |
|
58 | 58 | } |
59 | 59 | |
60 | - public function findAllRemoved(): QueryWorkerContract |
|
60 | + public function findAllRemoved (): QueryWorkerContract |
|
61 | 61 | { |
62 | 62 | disableSoftDeleteableFilter(); |
63 | 63 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ->andWhere('deletedAt', 'isnotnull'); |
66 | 66 | } |
67 | 67 | |
68 | - public function findRemoved($id, bool $abort = true): ?EntityContract |
|
68 | + public function findRemoved ($id, bool $abort = true): ?EntityContract |
|
69 | 69 | { |
70 | 70 | $entity = $this->findAllRemoved() |
71 | 71 | ->andWhere('id', '=', $id) |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | abort(404, 'Registro não encontrado'); |
81 | 81 | } |
82 | 82 | |
83 | - public function createEntity(): EntityContract |
|
83 | + public function createEntity (): EntityContract |
|
84 | 84 | { |
85 | 85 | $entityName = $this->getEntityName(); |
86 | 86 | |
87 | 87 | return new $entityName(); |
88 | 88 | } |
89 | 89 | |
90 | - public function remove(EntityContract $entity): EntityContract |
|
90 | + public function remove (EntityContract $entity): EntityContract |
|
91 | 91 | { |
92 | 92 | $this->getEntityManager() |
93 | 93 | ->remove($entity); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | return $this->createQueryWorker(); |
32 | 32 | } |
33 | 33 | |
34 | - public function findOneBy(array $criteria, bool $abort = true): ?EntityContract |
|
34 | + public function findOneBy(array $criteria, bool $abort = TRUE): ?EntityContract |
|
35 | 35 | { |
36 | 36 | $findAll = $this->findAll(); |
37 | 37 | |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | abort(404, 'Registro não encontrado'); |
50 | 50 | } |
51 | 51 | |
52 | - return null; |
|
52 | + return NULL; |
|
53 | 53 | } |
54 | 54 | |
55 | - public function find($id, bool $abort = true): ?EntityContract |
|
55 | + public function find($id, bool $abort = TRUE): ?EntityContract |
|
56 | 56 | { |
57 | 57 | return $this->findOneBy(['id' => $id], $abort); |
58 | 58 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | ->andWhere('deletedAt', 'isnotnull'); |
66 | 66 | } |
67 | 67 | |
68 | - public function findRemoved($id, bool $abort = true): ?EntityContract |
|
68 | + public function findRemoved($id, bool $abort = TRUE): ?EntityContract |
|
69 | 69 | { |
70 | 70 | $entity = $this->findAllRemoved() |
71 | 71 | ->andWhere('id', '=', $id) |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class ORMServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - public function register() |
|
9 | + public function register () |
|
10 | 10 | { |
11 | 11 | $this->app->register(\Bludata\Doctrine\Common\Providers\CommonServiceProvider::class); |
12 | 12 | $this->app->register(\LaravelDoctrine\Extensions\GedmoExtensionsServiceProvider::class); |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Support\ServiceProvider; |
6 | 6 | |
7 | -class ORMServiceProvider extends ServiceProvider |
|
8 | -{ |
|
7 | +class ORMServiceProvider extends ServiceProvider { |
|
9 | 8 | public function register() |
10 | 9 | { |
11 | 10 | $this->app->register(\Bludata\Doctrine\Common\Providers\CommonServiceProvider::class); |
@@ -31,9 +31,9 @@ discard block |
||
31 | 31 | private function getPropertiesFillable(): array |
32 | 32 | { |
33 | 33 | $allProperties = $this->getRepository() |
34 | - ->getClassMetadata() |
|
35 | - ->getReflectionClass() |
|
36 | - ->getProperties(); |
|
34 | + ->getClassMetadata() |
|
35 | + ->getReflectionClass() |
|
36 | + ->getProperties(); |
|
37 | 37 | |
38 | 38 | return array_filter($allProperties, function ($property) { |
39 | 39 | $existAnnotationToArray = array_filter((new AnnotationReader())->getPropertyAnnotations($property), function ($annotation) { |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function toArray(array $options = []): array |
48 | 48 | { |
49 | 49 | $classMetadata = $this->getRepository() |
50 | - ->getClassMetadata(); |
|
50 | + ->getClassMetadata(); |
|
51 | 51 | |
52 | 52 | $propertiesFillable = $this->getPropertiesFillable(); |
53 | 53 |
@@ -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 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | use Doctrine\ORM\PersistentCollection; |
10 | 10 | use ReflectionProperty; |
11 | 11 | |
12 | -trait ToArrayTrait |
|
13 | -{ |
|
12 | +trait ToArrayTrait { |
|
14 | 13 | private function isOnly(ReflectionProperty $property, array $optionsToArray): bool |
15 | 14 | { |
16 | 15 | if (!isset($optionsToArray['only']) && !isset($optionsToArray['except'])) { |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | private function isOnly(ReflectionProperty $property, array $optionsToArray): bool |
15 | 15 | { |
16 | 16 | if (!isset($optionsToArray['only']) && !isset($optionsToArray['except'])) { |
17 | - return true; |
|
17 | + return TRUE; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | if (isset($optionsToArray['only'])) { |
21 | 21 | if (in_array($property->getName(), $optionsToArray['only'])) { |
22 | - return true; |
|
22 | + return TRUE; |
|
23 | 23 | } |
24 | 24 | } else if (isset($optionsToArray['except']) && !in_array($property->getName(), $optionsToArray['except'])) { |
25 | - return true; |
|
25 | + return TRUE; |
|
26 | 26 | } |
27 | 27 | |
28 | - return false; |
|
28 | + return FALSE; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | private function getPropertiesFillable(): array |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | foreach ($propertiesFillable as $property) { |
57 | 57 | if ($this->isOnly($property, $options)) { |
58 | 58 | $key = $property->getName(); |
59 | - $metaDataKey = $classMetadata->hasField($key) ? $classMetadata->getFieldMapping($key) : null; |
|
59 | + $metaDataKey = $classMetadata->hasField($key) ? $classMetadata->getFieldMapping($key) : NULL; |
|
60 | 60 | |
61 | 61 | if (is_object($this->$key)) { |
62 | 62 | if ($this->$key instanceof DateTime) { |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | public function persist(): BdContracts\EntityContract |
126 | 126 | { |
127 | 127 | $this->getRepository() |
128 | - ->getEntityManager() |
|
129 | - ->persist($this); |
|
128 | + ->getEntityManager() |
|
129 | + ->persist($this); |
|
130 | 130 | |
131 | 131 | return $this; |
132 | 132 | } |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | public function flush(): BdContracts\EntityContract |
135 | 135 | { |
136 | 136 | $this->getRepository() |
137 | - ->getEntityManager() |
|
138 | - ->flush($this); |
|
137 | + ->getEntityManager() |
|
138 | + ->flush($this); |
|
139 | 139 | |
140 | 140 | return $this; |
141 | 141 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function remove(): BdContracts\EntityContract |
144 | 144 | { |
145 | 145 | $this->getRepository() |
146 | - ->remove($this); |
|
146 | + ->remove($this); |
|
147 | 147 | |
148 | 148 | return $this; |
149 | 149 | } |
@@ -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 |
@@ -150,7 +150,7 @@ |
||
150 | 150 | |
151 | 151 | public function undelete(): BdContracts\EntityContract |
152 | 152 | { |
153 | - $this->deletedAt = null; |
|
153 | + $this->deletedAt = NULL; |
|
154 | 154 | |
155 | 155 | $this->persist(); |
156 | 156 |
@@ -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 |
@@ -5,8 +5,7 @@ |
||
5 | 5 | use Doctrine\DBAL\Migrations\AbstractMigration; |
6 | 6 | use Doctrine\DBAL\Schema\Schema as Schema; |
7 | 7 | |
8 | -class Version20171016204335 extends AbstractMigration |
|
9 | -{ |
|
8 | +class Version20171016204335 extends AbstractMigration { |
|
10 | 9 | /** |
11 | 10 | * @param Schema $schema |
12 | 11 | */ |
@@ -10,8 +10,7 @@ |
||
10 | 10 | * @ORM\Entity(repositoryClass="LaravelSeed\Repositories\RotaRepository") |
11 | 11 | * @ORM\Table(name="Rota") |
12 | 12 | */ |
13 | -class Rota extends BaseEntity |
|
14 | -{ |
|
13 | +class Rota extends BaseEntity { |
|
15 | 14 | /** |
16 | 15 | * @ORM\Column(type="string", name="nome") |
17 | 16 | * @BdAnnotations\Fillable |