@@ -146,7 +146,7 @@ |
||
| 146 | 146 | * Create definition of routes for a route repository by a collection of endpoints |
| 147 | 147 | * |
| 148 | 148 | * @param array $resources |
| 149 | - * @return array |
|
| 149 | + * @return string|null |
|
| 150 | 150 | */ |
| 151 | 151 | protected function createRoutesDefinition(array $resources): array |
| 152 | 152 | { |
@@ -48,12 +48,12 @@ discard block |
||
| 48 | 48 | $loader->load('mapper.yml'); |
| 49 | 49 | $loader->load('http_client.yml'); |
| 50 | 50 | |
| 51 | - if (! empty($config['mappers'])) { |
|
| 52 | - $this->createMappers($config['mappers'], $container); |
|
| 51 | + if (!empty($config[ 'mappers' ])) { |
|
| 52 | + $this->createMappers($config[ 'mappers' ], $container); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if (! empty($config['http_clients'])) { |
|
| 56 | - $this->createResourceClients($config['http_clients'], $container); |
|
| 55 | + if (!empty($config[ 'http_clients' ])) { |
|
| 56 | + $this->createResourceClients($config[ 'http_clients' ], $container); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -70,16 +70,16 @@ discard block |
||
| 70 | 70 | foreach ($config as $name => $mapperDefinition) |
| 71 | 71 | { |
| 72 | 72 | $mapper = new DefinitionDecorator('mrtn_json_api.object_mapper.abstract'); |
| 73 | - $mapper->addTag('mrtn_json_api.object_mapper', ['alias' => $name]); |
|
| 73 | + $mapper->addTag('mrtn_json_api.object_mapper', [ 'alias' => $name ]); |
|
| 74 | 74 | |
| 75 | - foreach ($mapperDefinition['handlers'] as $handlerName) |
|
| 75 | + foreach ($mapperDefinition[ 'handlers' ] as $handlerName) |
|
| 76 | 76 | { |
| 77 | - if (! isset($handlers[$handlerName])) { |
|
| 77 | + if (!isset($handlers[ $handlerName ])) { |
|
| 78 | 78 | throw new \LogicException(sprintf('Mapping handler with name "%s" has not been registered as a service.', $handlerName)); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $mapper->addMethodCall('addHandler', [ |
| 82 | - new Reference($handlers[$handlerName]) |
|
| 82 | + new Reference($handlers[ $handlerName ]) |
|
| 83 | 83 | ]); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -97,17 +97,17 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $handlers = $container->findTaggedServiceIds('mrtn_json_api.object_mapper.handler'); |
| 99 | 99 | |
| 100 | - $found = []; |
|
| 100 | + $found = [ ]; |
|
| 101 | 101 | |
| 102 | 102 | foreach ($handlers as $id => $tags) |
| 103 | 103 | { |
| 104 | 104 | foreach ($tags as $tag) |
| 105 | 105 | { |
| 106 | - if (! isset($tag['alias'])) { |
|
| 106 | + if (!isset($tag[ 'alias' ])) { |
|
| 107 | 107 | continue; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - $found[$tag['alias']] = $id; |
|
| 110 | + $found[ $tag[ 'alias' ] ] = $id; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | foreach ($config as $name => $definition) |
| 129 | 129 | { |
| 130 | - $routes = $this->createRoutesDefinition($definition['resources']); |
|
| 130 | + $routes = $this->createRoutesDefinition($definition[ 'resources' ]); |
|
| 131 | 131 | |
| 132 | - $repository = new Definition($repositoryClass, [$definition['base_url'], $routes]); |
|
| 132 | + $repository = new Definition($repositoryClass, [ $definition[ 'base_url' ], $routes ]); |
|
| 133 | 133 | $repository->setPublic(false); |
| 134 | 134 | |
| 135 | 135 | $client = new Definition($clientClass, [ |
@@ -150,15 +150,15 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | protected function createRoutesDefinition(array $resources): array |
| 152 | 152 | { |
| 153 | - $definition = []; |
|
| 153 | + $definition = [ ]; |
|
| 154 | 154 | |
| 155 | 155 | foreach ($resources as $name => $resource) |
| 156 | 156 | { |
| 157 | - $methods = array_keys($resource['methods']); |
|
| 157 | + $methods = array_keys($resource[ 'methods' ]); |
|
| 158 | 158 | $methods = array_map('strtoupper', $methods); |
| 159 | 159 | |
| 160 | - $definition[$name] = [ |
|
| 161 | - 'path' => trim($resource['path']), |
|
| 160 | + $definition[ $name ] = [ |
|
| 161 | + 'path' => trim($resource[ 'path' ]), |
|
| 162 | 162 | 'methods' => array_map('trim', $methods) |
| 163 | 163 | ]; |
| 164 | 164 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * Get URL generator |
| 69 | 69 | * |
| 70 | - * @return UrlGeneratorInterface |
|
| 70 | + * @return \Symfony\Component\Routing\Generator\UrlGeneratorInterface |
|
| 71 | 71 | */ |
| 72 | 72 | protected function getUrlGenerator(): UrlGeneratorInterface |
| 73 | 73 | { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * Assemble routes collection |
| 86 | 86 | * |
| 87 | - * @return RouteCollection |
|
| 87 | + * @return \Symfony\Component\Routing\RouteCollection |
|
| 88 | 88 | */ |
| 89 | 89 | protected function assembleRoutesCollection(): RouteCollection |
| 90 | 90 | { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param array $parameters Request parameters |
| 60 | 60 | * @return string |
| 61 | 61 | */ |
| 62 | - public function generate(string $name, array $parameters = []): string |
|
| 62 | + public function generate(string $name, array $parameters = [ ]): string |
|
| 63 | 63 | { |
| 64 | 64 | return $this->getUrlGenerator()->generate($name, $parameters); |
| 65 | 65 | } |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | foreach ($this->routes as $name => $definition) |
| 94 | 94 | { |
| 95 | - $route = new Route($definition['path']); |
|
| 96 | - $route->setMethods($definition['methods']); |
|
| 95 | + $route = new Route($definition[ 'path' ]); |
|
| 96 | + $route->setMethods($definition[ 'methods' ]); |
|
| 97 | 97 | |
| 98 | 98 | $collection->add($name, $route); |
| 99 | 99 | } |
@@ -36,13 +36,13 @@ |
||
| 36 | 36 | protected function processMappers(NodeBuilder $builder): void |
| 37 | 37 | { |
| 38 | 38 | $builder->arrayNode('mappers') |
| 39 | - ->defaultValue(['default' => [ |
|
| 39 | + ->defaultValue([ 'default' => [ |
|
| 40 | 40 | 'handlers' => [ |
| 41 | 41 | 'attribute', |
| 42 | 42 | 'relationship', |
| 43 | 43 | 'link' |
| 44 | 44 | ] |
| 45 | - ]]) |
|
| 45 | + ] ]) |
|
| 46 | 46 | ->prototype('array') |
| 47 | 47 | ->children() |
| 48 | 48 | ->arrayNode('handlers') |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return ResponseInterface |
| 62 | 62 | */ |
| 63 | - public function request(string $method, string $resource, array $parameters = [], array $headers = [], $body = null): ResponseInterface |
|
| 63 | + public function request(string $method, string $resource, array $parameters = [ ], array $headers = [ ], $body = null): ResponseInterface |
|
| 64 | 64 | { |
| 65 | 65 | $uri = $this->repository->generate($resource, $parameters); |
| 66 | 66 | |
@@ -86,6 +86,6 @@ discard block |
||
| 86 | 86 | { |
| 87 | 87 | array_unshift(strtoupper($name), $arguments); |
| 88 | 88 | |
| 89 | - return call_user_func_array([$this, 'request'], $arguments); |
|
| 89 | + return call_user_func_array([ $this, 'request' ], $arguments); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |