Completed
Push — master ( e39a6b...d536ea )
by Jakub
01:57
created
src/Req2CmdBundle.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/EventListener/ExtractCommandFromRequestListener.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/CommandExtractor/SerializerCommandExtractor.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
         DecoderInterface $decoder,
37 37
         DenormalizerInterface $denormalizer
38 38
     ) {
39
-        $this->serializer = $serializer;
40
-        $this->decoder = $decoder;
41
-        $this->denormalizer = $denormalizer;
39
+        $this->serializer=$serializer;
40
+        $this->decoder=$decoder;
41
+        $this->denormalizer=$denormalizer;
42 42
     }
43 43
 
44 44
     /**
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
      * @throws \LogicException
47 47
      * @throws \Symfony\Component\Serializer\Exception\UnexpectedValueException
48 48
      */
49
-    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps = [])
49
+    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps=[])
50 50
     {
51 51
         if (!empty($additionalProps)) {
52
-            $decodedContent = $this->decoder->decode($request->getContent(), $request->getRequestFormat());
53
-            $finalProps = array_merge($decodedContent, $additionalProps);
52
+            $decodedContent=$this->decoder->decode($request->getContent(), $request->getRequestFormat());
53
+            $finalProps=array_merge($decodedContent, $additionalProps);
54 54
             return $this->denormalizer->denormalize($finalProps, $commandClass, $request->getRequestFormat());
55 55
         }
56 56
 
Please login to merge, or discard this patch.
src/CommandExtractor/JMSSerializerCommandExtractor.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,23 +26,23 @@
 block discarded – undo
26 26
      */
27 27
     public function __construct(SerializerInterface $jmsSerializer, ArrayTransformerInterface $jmsArrayTransformer)
28 28
     {
29
-        $this->jmsSerializer = $jmsSerializer;
30
-        $this->jmsArrayTransformer = $jmsArrayTransformer;
29
+        $this->jmsSerializer=$jmsSerializer;
30
+        $this->jmsArrayTransformer=$jmsArrayTransformer;
31 31
     }
32 32
 
33 33
     /**
34 34
      * {@inheritdoc}
35 35
      * @throws \LogicException
36 36
      */
37
-    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps = [])
37
+    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps=[])
38 38
     {
39 39
         if (!empty($additionalProps)) {
40
-            $decodedContent = $this->jmsSerializer->deserialize(
40
+            $decodedContent=$this->jmsSerializer->deserialize(
41 41
                 $request->getContent(),
42 42
                 'array',
43 43
                 $request->getRequestFormat()
44 44
             );
45
-            $finalProps = array_merge($decodedContent, $additionalProps);
45
+            $finalProps=array_merge($decodedContent, $additionalProps);
46 46
             return $this->jmsArrayTransformer->fromArray($finalProps, $commandClass);
47 47
         }
48 48
 
Please login to merge, or discard this patch.
src/CommandExtractor/CommandExtractorInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,5 +13,5 @@
 block discarded – undo
13 13
      * @param array $additionalProps
14 14
      * @return object
15 15
      */
16
-    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps = []);
16
+    public function extractFromRequest(Request $request, string $commandClass, array $additionalProps=[]);
17 17
 }
Please login to merge, or discard this patch.
src/CommandExtractor/MockCommandExtractor.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
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(func_get_args());
27
+        $paramsHash=serialize(func_get_args());
28 28
         if (array_key_exists($paramsHash, $this->toReturnForArgs)) {
29 29
             return $this->toReturnForArgs[$paramsHash];
30 30
         }
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
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
         } else {
40
-            $this->toReturn = $command;
40
+            $this->toReturn=$command;
41 41
         }
42 42
 
43 43
         return $this;
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
         return $this;
49 49
     }
50 50
 
51
-    public function forArguments(Request $request, string $cmdClass, array $additionalProps = []): self
51
+    public function forArguments(Request $request, string $cmdClass, array $additionalProps=[]): self
52 52
     {
53
-        $this->lastArgsHash = serialize(func_get_args());
53
+        $this->lastArgsHash=serialize(func_get_args());
54 54
 
55 55
         return $this;
56 56
     }
Please login to merge, or discard this patch.
src/Exception/ParamMapperException.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Serializer/DeserializableCommandDenormalizer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Params/ParameterMapper/PathParamsMapper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 class PathParamsMapper implements ParamMapperInterface
10 10
 {
11
-    private const REQ_CHAR = '!';
11
+    private const REQ_CHAR='!';
12 12
 
13 13
     public function map(Request $request, array $propsMap): array
14 14
     {
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
             return [];
17 17
         }
18 18
 
19
-        $pathProps = (array)$propsMap['path'];
20
-        $result = [];
19
+        $pathProps=(array) $propsMap['path'];
20
+        $result=[];
21 21
         foreach ($pathProps as $propName => $propValue) {
22
-            $required = false;
22
+            $required=false;
23 23
             if (strpos($propName, self::REQ_CHAR) === 0) {
24
-                $required = true;
25
-                $propName = ltrim($propName, self::REQ_CHAR);
24
+                $required=true;
25
+                $propName=ltrim($propName, self::REQ_CHAR);
26 26
             }
27 27
 
28 28
             if ($required && $request->attributes->has($propName) && empty($request->attributes->get($propName))) {
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
                 continue;
38 38
             }
39 39
 
40
-            $finalPropName = $propValue ?? $propName;
41
-            $result[$finalPropName] = $request->attributes->get($propName);
40
+            $finalPropName=$propValue ?? $propName;
41
+            $result[$finalPropName]=$request->attributes->get($propName);
42 42
         }
43 43
 
44 44
         return $result;
Please login to merge, or discard this patch.