@@ -27,7 +27,7 @@ |
||
27 | 27 | { |
28 | 28 | $entity = $this->getArtifact('entity'); |
29 | 29 | |
30 | - if(true !== $this->getArtifact('validation')) { |
|
30 | + if (true !== $this->getArtifact('validation')) { |
|
31 | 31 | return new ArtifactCollection(); |
32 | 32 | } |
33 | 33 |
@@ -23,6 +23,6 @@ |
||
23 | 23 | |
24 | 24 | $response = $step->execute($request); |
25 | 25 | $this->assertInstanceOf(ArtifactCollection::class, $response); |
26 | - $this->assertEquals([0 => ['type' => 'eq','property' => 'title','value' => 'test']], $response->get('filters')->getValue()); |
|
26 | + $this->assertEquals([0 => ['type' => 'eq', 'property' => 'title', 'value' => 'test']], $response->get('filters')->getValue()); |
|
27 | 27 | } |
28 | 28 | } |
@@ -216,7 +216,9 @@ |
||
216 | 216 | $annotation instanceof OneToMany || |
217 | 217 | $annotation instanceof ManyToOne || |
218 | 218 | $annotation instanceof ManyToMany |
219 | - ) $targetEntity = $annotation->targetEntity; |
|
219 | + ) { |
|
220 | + $targetEntity = $annotation->targetEntity; |
|
221 | + } |
|
220 | 222 | } |
221 | 223 | |
222 | 224 | return str_replace('_', '-', Inflector::tableize(substr($targetEntity, strripos($targetEntity, '\\') + 1))); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | private function getReturnedParams($route, $anonymousClass, $canAccessClass) |
178 | 178 | { |
179 | 179 | $reflection = $this->getEntityReflection($route->getDefault('_entity')); |
180 | - $availableParams = $reflection->getName() . "\n"; |
|
180 | + $availableParams = $reflection->getName()."\n"; |
|
181 | 181 | |
182 | 182 | foreach ($reflection->getProperties() as $property) { |
183 | 183 | $anonymous = $this->reader->getPropertyAnnotation($property, $anonymousClass); |
@@ -189,10 +189,9 @@ discard block |
||
189 | 189 | $availableAccess = $access ? $access->roles : $availableAccess; |
190 | 190 | $availableAccess = implode(', ', $availableAccess); |
191 | 191 | |
192 | - $availableParams .= Inflector::tableize($property->getName()) . ':'; |
|
193 | - $availableParams .= $relation ? '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">Related model</a>' : |
|
194 | - ($column ? $column->type : 'Unknown'); |
|
195 | - $availableParams .= ', Access: ' . $availableAccess . "\n"; |
|
192 | + $availableParams .= Inflector::tableize($property->getName()).':'; |
|
193 | + $availableParams .= $relation ? '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">Related model</a>' : ($column ? $column->type : 'Unknown'); |
|
194 | + $availableParams .= ', Access: '.$availableAccess."\n"; |
|
196 | 195 | } |
197 | 196 | } |
198 | 197 | |
@@ -246,8 +245,7 @@ discard block |
||
246 | 245 | |
247 | 246 | $param['description'] = $relation ? |
248 | 247 | '<a href="#operations-tag-'.$this->getRelatedPropertyModelName($property).'">'. |
249 | - 'Related model description</a><pre>Access: ' . $availableAccess . '</pre>' : |
|
250 | - '<pre>Access: ' . $availableAccess . '</pre>'; |
|
248 | + 'Related model description</a><pre>Access: '.$availableAccess.'</pre>' : '<pre>Access: '.$availableAccess.'</pre>'; |
|
251 | 249 | |
252 | 250 | $availableParams[] = $param; |
253 | 251 | } |
@@ -259,8 +257,8 @@ discard block |
||
259 | 257 | private function getRelatedPropertyModelName($property) |
260 | 258 | { |
261 | 259 | $annotations = $this->reader->getPropertyAnnotations($property); |
262 | - foreach ($annotations as $annotation){ |
|
263 | - if( |
|
260 | + foreach ($annotations as $annotation) { |
|
261 | + if ( |
|
264 | 262 | $annotation instanceof OneToOne || |
265 | 263 | $annotation instanceof OneToMany || |
266 | 264 | $annotation instanceof ManyToOne || |
@@ -50,23 +50,20 @@ |
||
50 | 50 | $reflection = $this->getArtifact('reflection'); |
51 | 51 | $query = 'e.%s'; |
52 | 52 | |
53 | - if(strripos($sort, '.')){ |
|
53 | + if (strripos($sort, '.')) { |
|
54 | 54 | $sort = explode('.', $sort); |
55 | - if($reflection->hasProperty(Inflector::camelize($sort[0]))){ |
|
55 | + if ($reflection->hasProperty(Inflector::camelize($sort[0]))) { |
|
56 | 56 | $property = $reflection->getProperty(Inflector::camelize($sort[0])); |
57 | - $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class)?: |
|
58 | - $this->reader->getPropertyAnnotation($property, OneToMany::class)?: |
|
59 | - $this->reader->getPropertyAnnotation($property, ManyToMany::class)?: |
|
60 | - $this->reader->getPropertyAnnotation($property, ManyToOne::class)?:null; |
|
61 | - if($ann){ |
|
57 | + $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class) ?: $this->reader->getPropertyAnnotation($property, OneToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToOne::class) ?: null; |
|
58 | + if ($ann) { |
|
62 | 59 | $reflection = new \ReflectionClass($ann->targetEntity); |
63 | - $query = $sort[0] . '.%s'; |
|
60 | + $query = $sort[0].'.%s'; |
|
64 | 61 | $sort = Inflector::camelize(($sort[1])); |
65 | - } else{ |
|
66 | - throw new BadRequestHttpException('Related property ' . Inflector::camelize($sort[0]) . ' isn\'t related model in sort field'); |
|
62 | + } else { |
|
63 | + throw new BadRequestHttpException('Related property '.Inflector::camelize($sort[0]).' isn\'t related model in sort field'); |
|
67 | 64 | } |
68 | - } else{ |
|
69 | - throw new BadRequestHttpException('Related property ' . Inflector::camelize($sort[0]) . ' not found in sort field'); |
|
65 | + } else { |
|
66 | + throw new BadRequestHttpException('Related property '.Inflector::camelize($sort[0]).' not found in sort field'); |
|
70 | 67 | } |
71 | 68 | } |
72 | 69 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | } else { |
58 | 58 | throw new BadRequestHttpException('Related property ' . $filtr[1] . ' not found in related model ' . $filtr[0] . ' in filter field'); |
59 | 59 | } |
60 | - }else{ |
|
60 | + } else{ |
|
61 | 61 | throw new BadRequestHttpException('Property ' . $filtr[0] . ' isn\'t related model in filter field'); |
62 | 62 | } |
63 | 63 | } else{ |
@@ -40,29 +40,26 @@ discard block |
||
40 | 40 | $reflection = $this->getArtifact('reflection'); |
41 | 41 | |
42 | 42 | $queryModel = 'e'; |
43 | - if(strripos($filter['property'], '.')){ |
|
43 | + if (strripos($filter['property'], '.')) { |
|
44 | 44 | $filtr = explode('.', $filter['property']); |
45 | - if($reflection->hasProperty(Inflector::camelize($filtr[0]))){ |
|
45 | + if ($reflection->hasProperty(Inflector::camelize($filtr[0]))) { |
|
46 | 46 | $property = $reflection->getProperty(Inflector::camelize($filtr[0])); |
47 | - $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class)?: |
|
48 | - $this->reader->getPropertyAnnotation($property, OneToMany::class)?: |
|
49 | - $this->reader->getPropertyAnnotation($property, ManyToMany::class)?: |
|
50 | - $this->reader->getPropertyAnnotation($property, ManyToOne::class)?:null; |
|
51 | - if($ann){ |
|
47 | + $ann = $this->reader->getPropertyAnnotation($property, OneToOne::class) ?: $this->reader->getPropertyAnnotation($property, OneToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToMany::class) ?: $this->reader->getPropertyAnnotation($property, ManyToOne::class) ?: null; |
|
48 | + if ($ann) { |
|
52 | 49 | $reflection = new \ReflectionClass($ann->targetEntity); |
53 | - if($reflection->hasProperty(Inflector::camelize($filtr[1]))){ |
|
50 | + if ($reflection->hasProperty(Inflector::camelize($filtr[1]))) { |
|
54 | 51 | $property = $reflection->getProperty(Inflector::camelize($filtr[1])); |
55 | 52 | $filter['property'] = Inflector::camelize($filtr[1]); |
56 | 53 | $queryBuilder->leftJoin(sprintf('e.%s', $filtr[0]), $filtr[0]{0}); |
57 | 54 | $queryModel = Inflector::camelize($filtr[0]{0}); |
58 | 55 | } else { |
59 | - throw new BadRequestHttpException('Related property ' . $filtr[1] . ' not found in related model ' . $filtr[0] . ' in filter field'); |
|
56 | + throw new BadRequestHttpException('Related property '.$filtr[1].' not found in related model '.$filtr[0].' in filter field'); |
|
60 | 57 | } |
61 | - }else{ |
|
62 | - throw new BadRequestHttpException('Property ' . $filtr[0] . ' isn\'t related model in filter field'); |
|
58 | + } else { |
|
59 | + throw new BadRequestHttpException('Property '.$filtr[0].' isn\'t related model in filter field'); |
|
63 | 60 | } |
64 | - } else{ |
|
65 | - throw new BadRequestHttpException('Related property ' . $filtr[0] . ' not found in filter field'); |
|
61 | + } else { |
|
62 | + throw new BadRequestHttpException('Related property '.$filtr[0].' not found in filter field'); |
|
66 | 63 | } |
67 | 64 | } |
68 | 65 | |
@@ -111,12 +108,12 @@ discard block |
||
111 | 108 | sprintf( |
112 | 109 | $queryModel.'.%s BETWEEN :%s_min_value AND :%s_max_value', |
113 | 110 | $filter['property'], |
114 | - $filter['property'].($index+10), |
|
115 | - $filter['property'].($index+11) |
|
111 | + $filter['property'].($index + 10), |
|
112 | + $filter['property'].($index + 11) |
|
116 | 113 | ) |
117 | 114 | ) |
118 | - ->setParameter(sprintf('%s_min_value', $filter['property'].($index+10)), $filter['min']) |
|
119 | - ->setParameter(sprintf('%s_max_value', $filter['property'].($index+11)), $filter['max']); |
|
115 | + ->setParameter(sprintf('%s_min_value', $filter['property'].($index + 10)), $filter['min']) |
|
116 | + ->setParameter(sprintf('%s_max_value', $filter['property'].($index + 11)), $filter['max']); |
|
120 | 117 | ; |
121 | 118 | } |
122 | 119 |
@@ -8,11 +8,11 @@ |
||
8 | 8 | |
9 | 9 | class ConfigurationTest extends TestCase |
10 | 10 | { |
11 | - public function testCanByConstructed () |
|
12 | - { |
|
13 | - $configuration = new Configuration(); |
|
14 | - $treeBuilder = $configuration->getConfigTreeBuilder(); |
|
11 | + public function testCanByConstructed () |
|
12 | + { |
|
13 | + $configuration = new Configuration(); |
|
14 | + $treeBuilder = $configuration->getConfigTreeBuilder(); |
|
15 | 15 | |
16 | - $this->assertInstanceOf(TreeBuilder::class, $treeBuilder); |
|
17 | - } |
|
16 | + $this->assertInstanceOf(TreeBuilder::class, $treeBuilder); |
|
17 | + } |
|
18 | 18 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | |
9 | 9 | class ConfigurationTest extends TestCase |
10 | 10 | { |
11 | - public function testCanByConstructed () |
|
11 | + public function testCanByConstructed() |
|
12 | 12 | { |
13 | 13 | $configuration = new Configuration(); |
14 | 14 | $treeBuilder = $configuration->getConfigTreeBuilder(); |
@@ -7,14 +7,14 @@ |
||
7 | 7 | |
8 | 8 | class ApiContextFactoryTest extends TestCase |
9 | 9 | { |
10 | - public function testCanBrCreated () |
|
10 | + public function testCanBrCreated() |
|
11 | 11 | { |
12 | 12 | $accessManagermMock = $this->createMock(AccessManager::class); |
13 | 13 | $contextFactory = new ApiContextFactory($accessManagermMock); |
14 | 14 | $this->assertInstanceOf(ApiContextFactory::class, $contextFactory); |
15 | 15 | } |
16 | 16 | |
17 | - public function testCreateSerializationContext () |
|
17 | + public function testCreateSerializationContext() |
|
18 | 18 | { |
19 | 19 | $accessManagermMock = $this->createMock(AccessManager::class); |
20 | 20 | $contextFactory = new ApiContextFactory($accessManagermMock); |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $this->assertInstanceOf(MyModel::class, $response->get('entity')->getValue()); |
50 | 50 | } |
51 | 51 | |
52 | - public function testFailureExecuteWithoutEntity () |
|
52 | + public function testFailureExecuteWithoutEntity() |
|
53 | 53 | { |
54 | 54 | $repositoryMock = $this->createMock(TestRepository::class); |
55 | 55 | $repositoryMock->expects($this->at(0))->method('find')->willReturn(null); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $registry->expects($this->any())->method('getRepository')->willReturn($repositoryMock); |
58 | 58 | $step = new FetchEntityByIdStep($registry); |
59 | 59 | $step->setArtifacts(new ArtifactCollection([ |
60 | - new Artifact('reflection', new \ReflectionClass(MyModel::class)) |
|
60 | + new Artifact('reflection', new \ReflectionClass(MyModel::class)) |
|
61 | 61 | ])); |
62 | 62 | |
63 | 63 | $this->expectException(NotFoundHttpException::class); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $this->expectException(BadRequestHttpException::class); |
35 | 35 | $request->attributes->set('filter', base64_encode('[{"type": "eq", "value": "test"}]')); |
36 | 36 | $this->expectException(BadRequestHttpException::class); |
37 | - new Validator($request); |
|
37 | + new Validator($request); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | } |
41 | 41 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | class FilterValidatorTest extends TestCase |
11 | 11 | { |
12 | 12 | |
13 | - public function testCanBeConstructed () |
|
13 | + public function testCanBeConstructed() |
|
14 | 14 | { |
15 | 15 | $request = new Request(); |
16 | 16 | $request->attributes->set('filter', base64_encode('[{"type": "eq", "property": "title", "value": "test"}]')); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $this->assertInstanceOf(Validator::class, $filterValidator); |
20 | 20 | } |
21 | 21 | |
22 | - public function testFilterRequestWithBadType () |
|
22 | + public function testFilterRequestWithBadType() |
|
23 | 23 | { |
24 | 24 | $this->expectException(BadRequestHttpException::class); |
25 | 25 | $request = new Request(); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | |
29 | 29 | } |
30 | 30 | |
31 | - public function testFilterRequestWithoutRequiredParameter () |
|
31 | + public function testFilterRequestWithoutRequiredParameter() |
|
32 | 32 | { |
33 | 33 | $request = new Request(); |
34 | 34 | $this->expectException(BadRequestHttpException::class); |