@@ -2,6 +2,5 @@ |
||
2 | 2 | |
3 | 3 | namespace LaravelSeed\Contracts\Repositories; |
4 | 4 | |
5 | -interface RotaRepositoryContract |
|
6 | -{ |
|
5 | +interface RotaRepositoryContract { |
|
7 | 6 | } |
@@ -9,8 +9,7 @@ |
||
9 | 9 | use Doctrine\ORM\EntityRepository; |
10 | 10 | use Doctrine\ORM\Mapping\ClassMetadata; |
11 | 11 | |
12 | -abstract class BaseRepository extends EntityRepository implements RepositoryContract |
|
13 | -{ |
|
12 | +abstract class BaseRepository extends EntityRepository implements RepositoryContract { |
|
14 | 13 | public function getEntityManager(): EntityManager |
15 | 14 | { |
16 | 15 | return parent::getEntityManager(); |
@@ -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) |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param string $file |
9 | 9 | */ |
10 | - function register_annotation_file(string $file) |
|
10 | + function register_annotation_file (string $file) |
|
11 | 11 | { |
12 | 12 | if (!is_file($file)) { |
13 | 13 | return false; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | /** |
25 | 25 | * @param string $dir |
26 | 26 | */ |
27 | - function register_annotation_dir(string $dir) |
|
27 | + function register_annotation_dir (string $dir) |
|
28 | 28 | { |
29 | 29 | if (!is_dir($dir)) { |
30 | 30 | return false; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | $handle = opendir($dir); |
34 | 34 | while ($path = readdir($handle)) { |
35 | - $toRegisterPath = implode(DIRECTORY_SEPARATOR, [$dir, $path]); |
|
35 | + $toRegisterPath = implode(DIRECTORY_SEPARATOR, [ $dir, $path ]); |
|
36 | 36 | register_annotation_file($toRegisterPath); |
37 | 37 | } |
38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * Retrieve all annotations of a giving object |
45 | 45 | */ |
46 | 46 | if (!function_exists('get_class_annotations')) { |
47 | - function get_class_annotations($element, $annotation = null) |
|
47 | + function get_class_annotations ($element, $annotation = null) |
|
48 | 48 | { |
49 | 49 | $class = $element; |
50 | 50 | if (is_object($element)) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Retrieve annotations of a especific property of a giving object |
63 | 63 | */ |
64 | 64 | if (!function_exists('get_property_annotations')) { |
65 | - function get_property_annotations($element, $property = null, $annotation = null) |
|
65 | + function get_property_annotations ($element, $property = null, $annotation = null) |
|
66 | 66 | { |
67 | 67 | $class = $element; |
68 | 68 | if (is_object($element) && !($element instanceof \ReflectionClass)) { |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | |
81 | 81 | $reflectClass = new \ReflectionClass($class); |
82 | 82 | $reflectProperties = $reflectClass->getProperties(); |
83 | - $annotations = []; |
|
83 | + $annotations = [ ]; |
|
84 | 84 | foreach ($reflectProperties as $property) { |
85 | - $annotations[$property->getName()] = get_property_annotations($reflectClass, $property, $annotation); |
|
85 | + $annotations[ $property->getName() ] = get_property_annotations($reflectClass, $property, $annotation); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | return $annotations; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | function register_annotation_file(string $file) |
11 | 11 | { |
12 | 12 | if (!is_file($file)) { |
13 | - return false; |
|
13 | + return FALSE; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | return \Doctrine\Common\Annotations\AnnotationRegistry::registerFile($file); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | function register_annotation_dir(string $dir) |
28 | 28 | { |
29 | 29 | if (!is_dir($dir)) { |
30 | - return false; |
|
30 | + return FALSE; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $handle = opendir($dir); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | register_annotation_file($toRegisterPath); |
37 | 37 | } |
38 | 38 | |
39 | - return true; |
|
39 | + return TRUE; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * Retrieve all annotations of a giving object |
45 | 45 | */ |
46 | 46 | if (!function_exists('get_class_annotations')) { |
47 | - function get_class_annotations($element, $annotation = null) |
|
47 | + function get_class_annotations($element, $annotation = NULL) |
|
48 | 48 | { |
49 | 49 | $class = $element; |
50 | 50 | if (is_object($element)) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * Retrieve annotations of a especific property of a giving object |
63 | 63 | */ |
64 | 64 | if (!function_exists('get_property_annotations')) { |
65 | - function get_property_annotations($element, $property = null, $annotation = null) |
|
65 | + function get_property_annotations($element, $property = NULL, $annotation = NULL) |
|
66 | 66 | { |
67 | 67 | $class = $element; |
68 | 68 | if (is_object($element) && !($element instanceof \ReflectionClass)) { |
@@ -5,8 +5,7 @@ |
||
5 | 5 | use Doctrine\ORM\EntityManager; |
6 | 6 | use Doctrine\ORM\Mapping\ClassMetadata; |
7 | 7 | |
8 | -interface RepositoryContract |
|
9 | -{ |
|
8 | +interface RepositoryContract { |
|
10 | 9 | public function getEntityManager(): EntityManager; |
11 | 10 | |
12 | 11 | public function getClassMetadata(): ClassMetadata; |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | interface RepositoryContract |
9 | 9 | { |
10 | - public function getEntityManager(): EntityManager; |
|
10 | + public function getEntityManager (): EntityManager; |
|
11 | 11 | |
12 | - public function getClassMetadata(): ClassMetadata; |
|
12 | + public function getClassMetadata (): ClassMetadata; |
|
13 | 13 | |
14 | - public function createQueryWorker(): QueryWorkerContract; |
|
14 | + public function createQueryWorker (): QueryWorkerContract; |
|
15 | 15 | |
16 | - public function findAll(): QueryWorkerContract; |
|
16 | + public function findAll (): QueryWorkerContract; |
|
17 | 17 | |
18 | - public function findOneBy(array $criteria, bool $abort = true): ?EntityContract; |
|
18 | + public function findOneBy (array $criteria, bool $abort = true): ?EntityContract; |
|
19 | 19 | |
20 | - public function find($id, bool $abort = true): ?EntityContract; |
|
20 | + public function find ($id, bool $abort = true): ?EntityContract; |
|
21 | 21 | |
22 | - public function findAllRemoved(): QueryWorkerContract; |
|
22 | + public function findAllRemoved (): QueryWorkerContract; |
|
23 | 23 | |
24 | - public function findRemoved($id, bool $abort = true): ?EntityContract; |
|
24 | + public function findRemoved ($id, bool $abort = true): ?EntityContract; |
|
25 | 25 | |
26 | - public function createEntity(): EntityContract; |
|
26 | + public function createEntity (): EntityContract; |
|
27 | 27 | |
28 | - public function remove(EntityContract $entity): EntityContract; |
|
28 | + public function remove (EntityContract $entity): EntityContract; |
|
29 | 29 | } |
@@ -15,13 +15,13 @@ |
||
15 | 15 | |
16 | 16 | public function findAll(): QueryWorkerContract; |
17 | 17 | |
18 | - public function findOneBy(array $criteria, bool $abort = true): ?EntityContract; |
|
18 | + public function findOneBy(array $criteria, bool $abort = TRUE): ?EntityContract; |
|
19 | 19 | |
20 | - public function find($id, bool $abort = true): ?EntityContract; |
|
20 | + public function find($id, bool $abort = TRUE): ?EntityContract; |
|
21 | 21 | |
22 | 22 | public function findAllRemoved(): QueryWorkerContract; |
23 | 23 | |
24 | - public function findRemoved($id, bool $abort = true): ?EntityContract; |
|
24 | + public function findRemoved($id, bool $abort = TRUE): ?EntityContract; |
|
25 | 25 | |
26 | 26 | public function createEntity(): EntityContract; |
27 | 27 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | /** |
8 | 8 | * @param string $key |
9 | 9 | */ |
10 | - function env($key, $defaultValue = '') |
|
10 | + function env ($key, $defaultValue = '') |
|
11 | 11 | { |
12 | 12 | $env = getenv($key); |
13 | 13 | if (!$env) { |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param string $input |
24 | 24 | */ |
25 | - function onlyNumbers(string $input) |
|
25 | + function onlyNumbers (string $input) |
|
26 | 26 | { |
27 | 27 | return preg_replace('/\D/i', '', $input); |
28 | 28 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param string $from = 'Y-m-d' |
35 | 35 | * @param string $to = 'obj' |
36 | 36 | */ |
37 | - function parseDate($date, string $from = 'Y-m-d', string $to = 'obj') |
|
37 | + function parseDate ($date, string $from = 'Y-m-d', string $to = 'obj') |
|
38 | 38 | { |
39 | 39 | if ($date instanceof DateTime && $to === 'obj') { |
40 | 40 | return $date; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Dump and die. |
70 | 70 | */ |
71 | 71 | if (!function_exists('dd')) { |
72 | - function dd() |
|
72 | + function dd () |
|
73 | 73 | { |
74 | 74 | $args = func_get_args(); |
75 | 75 | foreach ($args as $arg) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * Print and die |
84 | 84 | */ |
85 | 85 | if (!function_exists('pd')) { |
86 | - function pd() |
|
86 | + function pd () |
|
87 | 87 | { |
88 | 88 | $args = func_get_args(); |
89 | 89 | foreach ($args as $arg) { |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * Dump and return |
98 | 98 | */ |
99 | 99 | if (!function_exists('dr')) { |
100 | - function dr() |
|
100 | + function dr () |
|
101 | 101 | { |
102 | 102 | $args = func_get_args(); |
103 | 103 | $result = ''; |
@@ -110,7 +110,7 @@ |
||
110 | 110 | if ($type == 'boolean') { |
111 | 111 | $result = $arg ? 'true' : 'false'; |
112 | 112 | } else { |
113 | - $result = print_r($arg, true); |
|
113 | + $result = print_r($arg, TRUE); |
|
114 | 114 | } |
115 | 115 | $result = sprintf('(%s) %s', $type, $result); |
116 | 116 | } |
@@ -26,24 +26,24 @@ |
||
26 | 26 | */ |
27 | 27 | protected $alias; |
28 | 28 | |
29 | - public function getNome() |
|
29 | + public function getNome () |
|
30 | 30 | { |
31 | 31 | return $this->nome; |
32 | 32 | } |
33 | 33 | |
34 | - public function setNome($nome) |
|
34 | + public function setNome ($nome) |
|
35 | 35 | { |
36 | 36 | $this->nome = $nome; |
37 | 37 | |
38 | 38 | return $this; |
39 | 39 | } |
40 | 40 | |
41 | - public function getAlias() |
|
41 | + public function getAlias () |
|
42 | 42 | { |
43 | 43 | return $this->alias; |
44 | 44 | } |
45 | 45 | |
46 | - public function setAlias($alias) |
|
46 | + public function setAlias ($alias) |
|
47 | 47 | { |
48 | 48 | $this->alias = $alias; |
49 | 49 |
@@ -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 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function disableSoftDeleteableFilter() |
|
3 | +function disableSoftDeleteableFilter () |
|
4 | 4 | { |
5 | 5 | if (\EntityManager::getFilters()->isEnabled('soft-deleteable')) { |
6 | 6 | \EntityManager::getFilters()->disable('soft-deleteable'); |
7 | 7 | } |
8 | 8 | } |
9 | -function enableSoftDeleteableFilter() |
|
9 | +function enableSoftDeleteableFilter () |
|
10 | 10 | { |
11 | 11 | if (!\EntityManager::getFilters()->isEnabled('soft-deleteable')) { |
12 | 12 | \EntityManager::getFilters()->enable('soft-deleteable'); |
@@ -6,7 +6,7 @@ |
||
6 | 6 | |
7 | 7 | class LaravelServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - public function register() |
|
9 | + public function register () |
|
10 | 10 | { |
11 | 11 | $this->app->register(\Bludata\Doctrine\ORM\Providers\ORMServiceProvider::class); |
12 | 12 | } |
@@ -4,8 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use Illuminate\Support\ServiceProvider; |
6 | 6 | |
7 | -class LaravelServiceProvider extends ServiceProvider |
|
8 | -{ |
|
7 | +class LaravelServiceProvider extends ServiceProvider { |
|
9 | 8 | public function register() |
10 | 9 | { |
11 | 10 | $this->app->register(\Bludata\Doctrine\ORM\Providers\ORMServiceProvider::class); |
@@ -6,12 +6,12 @@ discard block |
||
6 | 6 | * @param string $repository |
7 | 7 | * @param string $entity |
8 | 8 | */ |
9 | - function bind_repository(string $repositoryInterface, string $repository, string $entity) |
|
9 | + function bind_repository (string $repositoryInterface, string $repository, string $entity) |
|
10 | 10 | { |
11 | 11 | app()->bind($repositoryInterface, function ($app) use ($repository, $entity) { |
12 | 12 | return new $repository( |
13 | - $app['em'], |
|
14 | - $app['em']->getClassMetaData($entity) |
|
13 | + $app[ 'em' ], |
|
14 | + $app[ 'em' ]->getClassMetaData($entity) |
|
15 | 15 | ); |
16 | 16 | }); |
17 | 17 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * @param string $className |
23 | 23 | */ |
24 | - function bdEntityName(string $className) |
|
24 | + function bdEntityName (string $className) |
|
25 | 25 | { |
26 | 26 | return config('bludata.generator.namespace.root').config('bludata.generator.namespace.entities').$className; |
27 | 27 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param string $className |
33 | 33 | */ |
34 | - function bdEntity(string $className) |
|
34 | + function bdEntity (string $className) |
|
35 | 35 | { |
36 | 36 | return app(bdEntityName($className)); |
37 | 37 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | /** |
42 | 42 | * @param string $className |
43 | 43 | */ |
44 | - function bdContractRepositoryName(string $className) |
|
44 | + function bdContractRepositoryName (string $className) |
|
45 | 45 | { |
46 | 46 | return config('bludata.generator.namespace.root').config('bludata.generator.namespace.contracts.repositories').$className.'ContractRepository'; |
47 | 47 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @param string $className |
53 | 53 | */ |
54 | - function bdRepositoryName(string $className) |
|
54 | + function bdRepositoryName (string $className) |
|
55 | 55 | { |
56 | 56 | return config('bludata.generator.namespace.root').config('bludata.generator.namespace.repositories').$className.'Repository'; |
57 | 57 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * @param string $className |
63 | 63 | */ |
64 | - function bdRepository(string $className) |
|
64 | + function bdRepository (string $className) |
|
65 | 65 | { |
66 | 66 | return app(bdContractRepositoryName($className)); |
67 | 67 | } |