Passed
Push — master ( 7c0cfc...7873b1 )
by Anton
04:31
created
tests/app/src/Controller/TestController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 
49 49
     public function input(InputScope $i)
50 50
     {
51
-        return 'value: ' . $i->withPrefix('section')->getValue('query', 'value');
51
+        return 'value: '.$i->withPrefix('section')->getValue('query', 'value');
52 52
     }
53 53
 
54 54
     public function error(): void
Please login to merge, or discard this patch.
src/Auth/Cycle/TokenStorage.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function load(string $id): ?TokenInterface
45 45
     {
46
-        if (strpos($id, ':') === false) {
46
+        if (strpos($id, ':') === false){
47 47
             return null;
48 48
         }
49 49
 
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
         /** @var Token $token */
53 53
         $token = $this->orm->getRepository(Token::class)->findByPK($pk);
54 54
 
55
-        if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) {
55
+        if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))){
56 56
             // hijacked or deleted
57 57
             return null;
58 58
         }
59 59
 
60 60
         $token->setSecretValue($hash);
61 61
 
62
-        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) {
62
+        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()){
63 63
             $this->delete($token);
64 64
             return null;
65 65
         }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface
74 74
     {
75
-        try {
75
+        try{
76 76
             $token = new Token(
77 77
                 $this->issueID(),
78 78
                 $this->randomHash(128),
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $this->em->persist($token)->run();
85 85
 
86 86
             return $token;
87
-        } catch (\Throwable $e) {
87
+        }catch (\Throwable $e){
88 88
             throw new TokenStorageException('Unable to create token', $e->getCode(), $e);
89 89
         }
90 90
     }
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function delete(TokenInterface $token): void
96 96
     {
97
-        try {
97
+        try{
98 98
             $this->em->delete($token)->run();
99
-        } catch (\Throwable $e) {
99
+        }catch (\Throwable $e){
100 100
             throw new TokenStorageException('Unable to delete token', $e->getCode(), $e);
101 101
         }
102 102
     }
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $this->orm->getSource(Token::class)->getTable()
116 116
         );
117 117
 
118
-        while ((clone $query)->where('id', $id)->count('id') !== 0) {
118
+        while ((clone $query)->where('id', $id)->count('id') !== 0){
119 119
             $id = $this->randomHash(64);
120 120
         }
121 121
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -43,7 +43,8 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public function load(string $id): ?TokenInterface
45 45
     {
46
-        if (strpos($id, ':') === false) {
46
+        if (strpos($id, ':') === false)
47
+        {
47 48
             return null;
48 49
         }
49 50
 
@@ -52,14 +53,16 @@  discard block
 block discarded – undo
52 53
         /** @var Token $token */
53 54
         $token = $this->orm->getRepository(Token::class)->findByPK($pk);
54 55
 
55
-        if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash))) {
56
+        if ($token === null || !hash_equals($token->getHashedValue(), hash('sha512', $hash)))
57
+        {
56 58
             // hijacked or deleted
57 59
             return null;
58 60
         }
59 61
 
60 62
         $token->setSecretValue($hash);
61 63
 
62
-        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime()) {
64
+        if ($token->getExpiresAt() !== null && $token->getExpiresAt() < new \DateTime())
65
+        {
63 66
             $this->delete($token);
64 67
             return null;
65 68
         }
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
      */
73 76
     public function create(array $payload, \DateTimeInterface $expiresAt = null): TokenInterface
74 77
     {
75
-        try {
78
+        try
79
+        {
76 80
             $token = new Token(
77 81
                 $this->issueID(),
78 82
                 $this->randomHash(128),
@@ -84,7 +88,9 @@  discard block
 block discarded – undo
84 88
             $this->em->persist($token)->run();
85 89
 
86 90
             return $token;
87
-        } catch (\Throwable $e) {
91
+        }
92
+        catch (\Throwable $e)
93
+        {
88 94
             throw new TokenStorageException('Unable to create token', $e->getCode(), $e);
89 95
         }
90 96
     }
@@ -94,9 +100,12 @@  discard block
 block discarded – undo
94 100
      */
95 101
     public function delete(TokenInterface $token): void
96 102
     {
97
-        try {
103
+        try
104
+        {
98 105
             $this->em->delete($token)->run();
99
-        } catch (\Throwable $e) {
106
+        }
107
+        catch (\Throwable $e)
108
+        {
100 109
             throw new TokenStorageException('Unable to delete token', $e->getCode(), $e);
101 110
         }
102 111
     }
@@ -115,7 +124,8 @@  discard block
 block discarded – undo
115 124
             $this->orm->getSource(Token::class)->getTable()
116 125
         );
117 126
 
118
-        while ((clone $query)->where('id', $id)->count('id') !== 0) {
127
+        while ((clone $query)->where('id', $id)->count('id') !== 0)
128
+        {
119 129
             $id = $this->randomHash(64);
120 130
         }
121 131
 
Please login to merge, or discard this patch.
src/Domain/CycleInterceptor.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
40 40
     {
41 41
         // todo: support singular ID
42
-        foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role) {
43
-            if (!isset($parameters[$parameter])) {
42
+        foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role){
43
+            if (!isset($parameters[$parameter])){
44 44
                 throw new ControllerException(
45 45
                     "Entity `{$role}` can not be found",
46 46
                     ControllerException::NOT_FOUND
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             }
49 49
 
50 50
             $entity = $this->orm->getRepository($role)->findByPK($parameters[$parameter]);
51
-            if ($entity === null) {
51
+            if ($entity === null){
52 52
                 throw new ControllerException(
53 53
                     "Entity `{$role}` can not be found",
54 54
                     ControllerException::NOT_FOUND
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
     private function getDeclaredEntities(string $controller, string $action): array
70 70
     {
71 71
         $key = sprintf("%s:%s", $controller, $action);
72
-        if (array_key_exists($key, $this->entityCache)) {
72
+        if (array_key_exists($key, $this->entityCache)){
73 73
             return $this->entityCache[$key];
74 74
         }
75 75
 
76 76
         $this->entityCache[$key] = [];
77
-        try {
77
+        try{
78 78
             $method = new \ReflectionMethod($controller, $action);
79
-        } catch (\ReflectionException $e) {
79
+        }catch (\ReflectionException $e){
80 80
             return [];
81 81
         }
82 82
 
83
-        foreach ($method->getParameters() as $parameter) {
84
-            if ($parameter->getClass() === null) {
83
+        foreach ($method->getParameters() as $parameter){
84
+            if ($parameter->getClass() === null){
85 85
                 continue;
86 86
             }
87 87
 
88
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
88
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){
89 89
                 $this->entityCache[$key][$parameter->getName()] = $parameter->getClass()->getName();
90 90
             }
91 91
         }
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,8 +39,10 @@  discard block
 block discarded – undo
39 39
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
40 40
     {
41 41
         // todo: support singular ID
42
-        foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role) {
43
-            if (!isset($parameters[$parameter])) {
42
+        foreach ($this->getDeclaredEntities($controller, $action) as $parameter => $role)
43
+        {
44
+            if (!isset($parameters[$parameter]))
45
+            {
44 46
                 throw new ControllerException(
45 47
                     "Entity `{$role}` can not be found",
46 48
                     ControllerException::NOT_FOUND
@@ -48,7 +50,8 @@  discard block
 block discarded – undo
48 50
             }
49 51
 
50 52
             $entity = $this->orm->getRepository($role)->findByPK($parameters[$parameter]);
51
-            if ($entity === null) {
53
+            if ($entity === null)
54
+            {
52 55
                 throw new ControllerException(
53 56
                     "Entity `{$role}` can not be found",
54 57
                     ControllerException::NOT_FOUND
@@ -69,23 +72,30 @@  discard block
 block discarded – undo
69 72
     private function getDeclaredEntities(string $controller, string $action): array
70 73
     {
71 74
         $key = sprintf("%s:%s", $controller, $action);
72
-        if (array_key_exists($key, $this->entityCache)) {
75
+        if (array_key_exists($key, $this->entityCache))
76
+        {
73 77
             return $this->entityCache[$key];
74 78
         }
75 79
 
76 80
         $this->entityCache[$key] = [];
77
-        try {
81
+        try
82
+        {
78 83
             $method = new \ReflectionMethod($controller, $action);
79
-        } catch (\ReflectionException $e) {
84
+        }
85
+        catch (\ReflectionException $e)
86
+        {
80 87
             return [];
81 88
         }
82 89
 
83
-        foreach ($method->getParameters() as $parameter) {
84
-            if ($parameter->getClass() === null) {
90
+        foreach ($method->getParameters() as $parameter)
91
+        {
92
+            if ($parameter->getClass() === null)
93
+            {
85 94
                 continue;
86 95
             }
87 96
 
88
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
97
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName()))
98
+            {
89 99
                 $this->entityCache[$key][$parameter->getName()] = $parameter->getClass()->getName();
90 100
             }
91 101
         }
Please login to merge, or discard this patch.
src/Domain/FilterInterceptor.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
50 50
     {
51
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
52
-            if (isset($parameters[$parameter])) {
51
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
52
+            if (isset($parameters[$parameter])){
53 53
                 continue;
54 54
             }
55 55
 
56 56
             /** @var FilterInterface $filter */
57 57
             $filter = $this->container->get($filterClass);
58 58
 
59
-            if (!$filter->isValid()) {
59
+            if (!$filter->isValid()){
60 60
                 return $this->renderInvalid($filter);
61 61
             }
62 62
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     private function renderInvalid(FilterInterface $filter)
74 74
     {
75
-        switch ($this->strategy) {
75
+        switch ($this->strategy){
76 76
             case self::STRATEGY_JSON_RESPONSE:
77 77
                 return [
78 78
                     'status' => 400,
@@ -91,23 +91,23 @@  discard block
 block discarded – undo
91 91
     private function getDeclaredFilters(string $controller, string $action): array
92 92
     {
93 93
         $key = sprintf("%s:%s", $controller, $action);
94
-        if (array_key_exists($key, $this->filterCache)) {
94
+        if (array_key_exists($key, $this->filterCache)){
95 95
             return $this->filterCache[$key];
96 96
         }
97 97
 
98 98
         $this->filterCache[$key] = [];
99
-        try {
99
+        try{
100 100
             $method = new \ReflectionMethod($controller, $action);
101
-        } catch (\ReflectionException $e) {
101
+        }catch (\ReflectionException $e){
102 102
             return [];
103 103
         }
104 104
 
105
-        foreach ($method->getParameters() as $parameter) {
106
-            if ($parameter->getClass() === null) {
105
+        foreach ($method->getParameters() as $parameter){
106
+            if ($parameter->getClass() === null){
107 107
                 continue;
108 108
             }
109 109
 
110
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
110
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class)){
111 111
                 $this->filterCache[$key][$parameter->getName()] = $parameter->getClass()->getName();
112 112
             }
113 113
         }
Please login to merge, or discard this patch.
Braces   +21 added lines, -10 removed lines patch added patch discarded remove patch
@@ -48,15 +48,18 @@  discard block
 block discarded – undo
48 48
      */
49 49
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
50 50
     {
51
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
52
-            if (isset($parameters[$parameter])) {
51
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
52
+        {
53
+            if (isset($parameters[$parameter]))
54
+            {
53 55
                 continue;
54 56
             }
55 57
 
56 58
             /** @var FilterInterface $filter */
57 59
             $filter = $this->container->get($filterClass);
58 60
 
59
-            if (!$filter->isValid()) {
61
+            if (!$filter->isValid())
62
+            {
60 63
                 return $this->renderInvalid($filter);
61 64
             }
62 65
 
@@ -72,7 +75,8 @@  discard block
 block discarded – undo
72 75
      */
73 76
     private function renderInvalid(FilterInterface $filter)
74 77
     {
75
-        switch ($this->strategy) {
78
+        switch ($this->strategy)
79
+        {
76 80
             case self::STRATEGY_JSON_RESPONSE:
77 81
                 return [
78 82
                     'status' => 400,
@@ -91,23 +95,30 @@  discard block
 block discarded – undo
91 95
     private function getDeclaredFilters(string $controller, string $action): array
92 96
     {
93 97
         $key = sprintf("%s:%s", $controller, $action);
94
-        if (array_key_exists($key, $this->filterCache)) {
98
+        if (array_key_exists($key, $this->filterCache))
99
+        {
95 100
             return $this->filterCache[$key];
96 101
         }
97 102
 
98 103
         $this->filterCache[$key] = [];
99
-        try {
104
+        try
105
+        {
100 106
             $method = new \ReflectionMethod($controller, $action);
101
-        } catch (\ReflectionException $e) {
107
+        }
108
+        catch (\ReflectionException $e)
109
+        {
102 110
             return [];
103 111
         }
104 112
 
105
-        foreach ($method->getParameters() as $parameter) {
106
-            if ($parameter->getClass() === null) {
113
+        foreach ($method->getParameters() as $parameter)
114
+        {
115
+            if ($parameter->getClass() === null)
116
+            {
107 117
                 continue;
108 118
             }
109 119
 
110
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
120
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class))
121
+            {
111 122
                 $this->filterCache[$key][$parameter->getName()] = $parameter->getClass()->getName();
112 123
             }
113 124
         }
Please login to merge, or discard this patch.