@@ -12,7 +12,7 @@ |
||
| 12 | 12 | public function getContainerExtension(): Extension |
| 13 | 13 | { |
| 14 | 14 | if ($this->extension === null) { |
| 15 | - $this->extension = new Req2CmdExtension(); |
|
| 15 | + $this->extension=new Req2CmdExtension(); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | return $this->extension; |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class ExtractCommandFromRequestListener |
| 12 | 12 | { |
| 13 | - public const API_RESPONDER_CONTROLLER = 'eps.req2cmd.action.api_responder'; |
|
| 14 | - public const CMD_CLASS_PARAM = '_command_class'; |
|
| 15 | - public const CMD_PARAM = '_command'; |
|
| 16 | - public const CMD_PROPS_PARAM = '_command_properties'; |
|
| 17 | - private const CONTROLLER_PARAM = '_controller'; |
|
| 13 | + public const API_RESPONDER_CONTROLLER='eps.req2cmd.action.api_responder'; |
|
| 14 | + public const CMD_CLASS_PARAM='_command_class'; |
|
| 15 | + public const CMD_PARAM='_command'; |
|
| 16 | + public const CMD_PROPS_PARAM='_command_properties'; |
|
| 17 | + private const CONTROLLER_PARAM='_controller'; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @var CommandExtractorInterface |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function __construct(CommandExtractorInterface $extractor, ParamCollectorInterface $paramCollector) |
| 30 | 30 | { |
| 31 | - $this->extractor = $extractor; |
|
| 32 | - $this->paramCollector = $paramCollector; |
|
| 31 | + $this->extractor=$extractor; |
|
| 32 | + $this->paramCollector=$paramCollector; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function onKernelRequest(GetResponseEvent $event): void |
| 36 | 36 | { |
| 37 | - $request = $event->getRequest(); |
|
| 38 | - $commandClass = $request->attributes->get(self::CMD_CLASS_PARAM); |
|
| 37 | + $request=$event->getRequest(); |
|
| 38 | + $commandClass=$request->attributes->get(self::CMD_CLASS_PARAM); |
|
| 39 | 39 | if ($commandClass === null) { |
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $additionalParams = $this->extractAdditionalParams($request); |
|
| 44 | - $command = $this->extractor->extractFromRequest($request, $commandClass, $additionalParams); |
|
| 43 | + $additionalParams=$this->extractAdditionalParams($request); |
|
| 44 | + $command=$this->extractor->extractFromRequest($request, $commandClass, $additionalParams); |
|
| 45 | 45 | |
| 46 | 46 | $request->attributes->set(self::CMD_PARAM, $command); |
| 47 | 47 | $request->attributes->remove(self::CMD_CLASS_PARAM); |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | private function extractAdditionalParams(Request $request): array |
| 55 | 55 | { |
| 56 | - $additionalParams = []; |
|
| 56 | + $additionalParams=[]; |
|
| 57 | 57 | if ($request->attributes->has(self::CMD_PROPS_PARAM)) { |
| 58 | - $additionalProps = $request->attributes->get(self::CMD_PROPS_PARAM); |
|
| 59 | - $additionalParams = $this->paramCollector->collect($request, $additionalProps); |
|
| 58 | + $additionalProps=$request->attributes->get(self::CMD_PROPS_PARAM); |
|
| 59 | + $additionalParams=$this->paramCollector->collect($request, $additionalProps); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | return $additionalParams; |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | |
| 8 | 8 | final class ParamMapperException extends LogicException implements Req2CmdExceptionInterface |
| 9 | 9 | { |
| 10 | - public static function noParamFound(string $paramName, \Throwable $previous = null): self |
|
| 10 | + public static function noParamFound(string $paramName, \Throwable $previous=null): self |
|
| 11 | 11 | { |
| 12 | - $excCode = 101; |
|
| 13 | - $message = sprintf('Parameter "%s" is required and it\'s missing in your request', $paramName); |
|
| 12 | + $excCode=101; |
|
| 13 | + $message=sprintf('Parameter "%s" is required and it\'s missing in your request', $paramName); |
|
| 14 | 14 | return new self($message, $excCode, $previous); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public static function paramEmpty(string $paramName, \Throwable $previous = null): self |
|
| 17 | + public static function paramEmpty(string $paramName, \Throwable $previous=null): self |
|
| 18 | 18 | { |
| 19 | - $excCode = 102; |
|
| 20 | - $message = sprintf('The value of the parameter "%s" cannot be empty', $paramName); |
|
| 19 | + $excCode=102; |
|
| 20 | + $message=sprintf('The value of the parameter "%s" cannot be empty', $paramName); |
|
| 21 | 21 | return new self($message, $excCode, $previous); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -11,18 +11,18 @@ |
||
| 11 | 11 | /** |
| 12 | 12 | * {@inheritdoc} |
| 13 | 13 | */ |
| 14 | - public function denormalize($data, $class, $format = null, array $context = []) |
|
| 14 | + public function denormalize($data, $class, $format=null, array $context=[]) |
|
| 15 | 15 | { |
| 16 | - return call_user_func($class . '::fromArray', $data); |
|
| 16 | + return call_user_func($class.'::fromArray', $data); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * {@inheritdoc} |
| 21 | 21 | * @throws \ReflectionException |
| 22 | 22 | */ |
| 23 | - public function supportsDenormalization($data, $type, $format = null): bool |
|
| 23 | + public function supportsDenormalization($data, $type, $format=null): bool |
|
| 24 | 24 | { |
| 25 | - $reflClass = new \ReflectionClass($type); |
|
| 25 | + $reflClass=new \ReflectionClass($type); |
|
| 26 | 26 | return $reflClass->implementsInterface(DeserializableCommandInterface::class); |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function __construct(array $mappers) |
| 17 | 17 | { |
| 18 | - $this->mappers = []; |
|
| 18 | + $this->mappers=[]; |
|
| 19 | 19 | foreach ($mappers as $mapper) { |
| 20 | 20 | $this->addMapper($mapper); |
| 21 | 21 | } |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | { |
| 26 | 26 | return array_reduce( |
| 27 | 27 | $this->mappers, |
| 28 | - function (array $carry, ParamMapperInterface $mapper) use ($request, $propsMap) { |
|
| 29 | - $carry = array_merge($carry, $mapper->map($request, $propsMap)); |
|
| 28 | + function(array $carry, ParamMapperInterface $mapper) use ($request, $propsMap) { |
|
| 29 | + $carry=array_merge($carry, $mapper->map($request, $propsMap)); |
|
| 30 | 30 | return $carry; |
| 31 | 31 | }, |
| 32 | 32 | [] |
@@ -35,6 +35,6 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | private function addMapper(ParamMapperInterface $mapper): void |
| 37 | 37 | { |
| 38 | - $this->mappers[] = $mapper; |
|
| 38 | + $this->mappers[]=$mapper; |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | |
| 15 | 15 | public function __construct(CommandBus $commandBus) |
| 16 | 16 | { |
| 17 | - $this->commandBus = $commandBus; |
|
| 17 | + $this->commandBus=$commandBus; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function handleCommand($command): void |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | public function __construct(CommandBusInterface $commandBus) |
| 18 | 18 | { |
| 19 | - $this->commandBus = $commandBus; |
|
| 19 | + $this->commandBus=$commandBus; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function __invoke(Request $request): Response |
| 23 | 23 | { |
| 24 | - $command = $request->attributes->get('_command'); |
|
| 24 | + $command=$request->attributes->get('_command'); |
|
| 25 | 25 | if ($command === null) { |
| 26 | 26 | throw new \InvalidArgumentException('No _command argument found for action'); |
| 27 | 27 | } |
@@ -34,16 +34,16 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | switch ($request->getMethod()) { |
| 36 | 36 | case Request::METHOD_PUT: |
| 37 | - $statusCode = Response::HTTP_OK; |
|
| 37 | + $statusCode=Response::HTTP_OK; |
|
| 38 | 38 | break; |
| 39 | 39 | case Request::METHOD_POST: |
| 40 | - $statusCode = Response::HTTP_CREATED; |
|
| 40 | + $statusCode=Response::HTTP_CREATED; |
|
| 41 | 41 | break; |
| 42 | 42 | case Request::METHOD_DELETE: |
| 43 | - $statusCode = Response::HTTP_NO_CONTENT; |
|
| 43 | + $statusCode=Response::HTTP_NO_CONTENT; |
|
| 44 | 44 | break; |
| 45 | 45 | default: |
| 46 | - $statusCode = Response::HTTP_OK; |
|
| 46 | + $statusCode=Response::HTTP_OK; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | return $statusCode; |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public function getConfigTreeBuilder(): TreeBuilder |
| 17 | 17 | { |
| 18 | - $builder = new TreeBuilder(); |
|
| 18 | + $builder=new TreeBuilder(); |
|
| 19 | 19 | |
| 20 | - $root = $builder->root('req2cmd'); |
|
| 20 | + $root=$builder->root('req2cmd'); |
|
| 21 | 21 | $root |
| 22 | 22 | ->children() |
| 23 | 23 | ->append($this->addExtractorNode()) |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | private function addExtractorNode(): NodeDefinition |
| 32 | 32 | { |
| 33 | - $builder = new TreeBuilder(); |
|
| 34 | - $root = $builder->root('extractor'); |
|
| 33 | + $builder=new TreeBuilder(); |
|
| 34 | + $root=$builder->root('extractor'); |
|
| 35 | 35 | $root |
| 36 | 36 | ->addDefaultsIfNotSet() |
| 37 | 37 | ->beforeNormalization() |
| 38 | 38 | ->ifString() |
| 39 | - ->then(function ($extractorName) { |
|
| 40 | - return ['service_id' => 'eps.req2cmd.extractor.' . $extractorName]; |
|
| 39 | + ->then(function($extractorName) { |
|
| 40 | + return ['service_id' => 'eps.req2cmd.extractor.'.$extractorName]; |
|
| 41 | 41 | }) |
| 42 | 42 | ->end() |
| 43 | 43 | ->children() |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | private function addCommandBusNode(): NodeDefinition |
| 54 | 54 | { |
| 55 | - $builder = new TreeBuilder(); |
|
| 56 | - $node = $builder->root('command_bus'); |
|
| 55 | + $builder=new TreeBuilder(); |
|
| 56 | + $node=$builder->root('command_bus'); |
|
| 57 | 57 | $node |
| 58 | 58 | ->addDefaultsIfNotSet() |
| 59 | 59 | ->beforeNormalization() |
| 60 | 60 | ->ifString() |
| 61 | - ->then(function (string $svcId) { |
|
| 62 | - return ['service_id' => 'eps.req2cmd.command_bus.' . $svcId]; |
|
| 61 | + ->then(function(string $svcId) { |
|
| 62 | + return ['service_id' => 'eps.req2cmd.command_bus.'.$svcId]; |
|
| 63 | 63 | }) |
| 64 | 64 | ->end() |
| 65 | 65 | ->children() |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | ->end() |
| 74 | 74 | ->end() |
| 75 | 75 | ->validate() |
| 76 | - ->ifTrue(function ($config) { |
|
| 76 | + ->ifTrue(function($config) { |
|
| 77 | 77 | return $config['service_id'] !== 'eps.req2cmd.command_bus.tactician'; |
| 78 | 78 | }) |
| 79 | - ->then(function ($config) { |
|
| 79 | + ->then(function($config) { |
|
| 80 | 80 | unset($config['name']); |
| 81 | 81 | return $config; |
| 82 | 82 | }) |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | private function addEventListenersNode(): NodeDefinition |
| 89 | 89 | { |
| 90 | - $builder = new TreeBuilder(); |
|
| 91 | - $node = $builder->root('listeners'); |
|
| 90 | + $builder=new TreeBuilder(); |
|
| 91 | + $node=$builder->root('listeners'); |
|
| 92 | 92 | |
| 93 | 93 | $node |
| 94 | 94 | ->addDefaultsIfNotSet() |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | ->arrayNode('extractor') |
| 97 | 97 | ->addDefaultsIfNotSet() |
| 98 | 98 | ->beforeNormalization() |
| 99 | - ->ifTrue(function ($enabled) { return is_bool($enabled); }) |
|
| 100 | - ->then(function ($isEnabled) { |
|
| 99 | + ->ifTrue(function($enabled) { return is_bool($enabled); }) |
|
| 100 | + ->then(function($isEnabled) { |
|
| 101 | 101 | return ['enabled' => $isEnabled]; |
| 102 | 102 | }) |
| 103 | 103 | ->end() |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | public function __construct() |
| 18 | 18 | { |
| 19 | - $this->toReturnForArgs = []; |
|
| 19 | + $this->toReturnForArgs=[]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * {@inheritdoc} |
| 24 | 24 | */ |
| 25 | - public function extractFromRequest(Request $request, string $commandClass, array $additionalProps = []) |
|
| 25 | + public function extractFromRequest(Request $request, string $commandClass, array $additionalProps=[]) |
|
| 26 | 26 | { |
| 27 | - $paramsHash = serialize([$request, $commandClass, $additionalProps]); |
|
| 27 | + $paramsHash=serialize([$request, $commandClass, $additionalProps]); |
|
| 28 | 28 | if (array_key_exists($paramsHash, $this->toReturnForArgs)) { |
| 29 | 29 | return $this->toReturnForArgs[$paramsHash]; |
| 30 | 30 | } |
@@ -35,11 +35,11 @@ discard block |
||
| 35 | 35 | public function willReturn($command): self |
| 36 | 36 | { |
| 37 | 37 | if ($this->lastArgsHash !== null) { |
| 38 | - $this->toReturnForArgs[$this->lastArgsHash] = $command; |
|
| 38 | + $this->toReturnForArgs[$this->lastArgsHash]=$command; |
|
| 39 | 39 | return $this; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $this->toReturn = $command; |
|
| 42 | + $this->toReturn=$command; |
|
| 43 | 43 | |
| 44 | 44 | return $this; |
| 45 | 45 | } |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | return $this; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function forArguments(Request $request, string $cmdClass, array $additionalProps = []): self |
|
| 52 | + public function forArguments(Request $request, string $cmdClass, array $additionalProps=[]): self |
|
| 53 | 53 | { |
| 54 | - $this->lastArgsHash = serialize([$request, $cmdClass, $additionalProps]); |
|
| 54 | + $this->lastArgsHash=serialize([$request, $cmdClass, $additionalProps]); |
|
| 55 | 55 | |
| 56 | 56 | return $this; |
| 57 | 57 | } |