Passed
Push — master ( b12120...7f2d87 )
by Valentin
04:10 queued 01:33
created
src/Bootloader/Auth/AuthBootloader.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function getActor(TokenInterface $token): ?object
54 54
     {
55
-        foreach ($this->getProviders() as $provider) {
56
-            if (!$provider instanceof ActorProviderInterface) {
55
+        foreach ($this->getProviders() as $provider){
56
+            if (!$provider instanceof ActorProviderInterface){
57 57
                 throw new AuthException(
58 58
                     sprintf(
59 59
                         'Expected `ActorProviderInterface`, got `%s`',
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
             }
64 64
 
65 65
             $actor = $provider->getActor($token);
66
-            if ($actor !== null) {
66
+            if ($actor !== null){
67 67
                 return $actor;
68 68
             }
69 69
         }
70 70
 
71
-        if ($this->actorProvider === []) {
71
+        if ($this->actorProvider === []){
72 72
             throw new AuthException('No actor provider');
73 73
         }
74 74
 
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
      */
91 91
     private function getProviders(): \Generator
92 92
     {
93
-        foreach ($this->actorProvider as $provider) {
94
-            if ($provider instanceof Autowire) {
93
+        foreach ($this->actorProvider as $provider){
94
+            if ($provider instanceof Autowire){
95 95
                 yield $provider->resolve($this->factory);
96 96
                 continue;
97 97
             }
98 98
 
99
-            if (is_object($provider)) {
99
+            if (is_object($provider)){
100 100
                 yield $provider;
101 101
                 continue;
102 102
             }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,8 +52,10 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function getActor(TokenInterface $token): ?object
54 54
     {
55
-        foreach ($this->getProviders() as $provider) {
56
-            if (!$provider instanceof ActorProviderInterface) {
55
+        foreach ($this->getProviders() as $provider)
56
+        {
57
+            if (!$provider instanceof ActorProviderInterface)
58
+            {
57 59
                 throw new AuthException(
58 60
                     sprintf(
59 61
                         'Expected `ActorProviderInterface`, got `%s`',
@@ -63,12 +65,14 @@  discard block
 block discarded – undo
63 65
             }
64 66
 
65 67
             $actor = $provider->getActor($token);
66
-            if ($actor !== null) {
68
+            if ($actor !== null)
69
+            {
67 70
                 return $actor;
68 71
             }
69 72
         }
70 73
 
71
-        if ($this->actorProvider === []) {
74
+        if ($this->actorProvider === [])
75
+        {
72 76
             throw new AuthException('No actor provider');
73 77
         }
74 78
 
@@ -90,13 +94,16 @@  discard block
 block discarded – undo
90 94
      */
91 95
     private function getProviders(): \Generator
92 96
     {
93
-        foreach ($this->actorProvider as $provider) {
94
-            if ($provider instanceof Autowire) {
97
+        foreach ($this->actorProvider as $provider)
98
+        {
99
+            if ($provider instanceof Autowire)
100
+            {
95 101
                 yield $provider->resolve($this->factory);
96 102
                 continue;
97 103
             }
98 104
 
99
-            if (is_object($provider)) {
105
+            if (is_object($provider))
106
+            {
100 107
                 yield $provider;
101 108
                 continue;
102 109
             }
Please login to merge, or discard this patch.
tests/Framework/Validation/EntityCheckerTest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,7 @@
 block discarded – undo
142 142
             ['value' => $value] + $data,
143 143
             ['value' => [['entity::unique', User::class, $field, $fields]]]
144 144
         );
145
-        if ($context !== null) {
145
+        if ($context !== null){
146 146
             $validator = $validator->withContext($context);
147 147
         }
148 148
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -142,7 +142,8 @@
 block discarded – undo
142 142
             ['value' => $value] + $data,
143 143
             ['value' => [['entity::unique', User::class, $field, $fields]]]
144 144
         );
145
-        if ($context !== null) {
145
+        if ($context !== null)
146
+        {
146 147
             $validator = $validator->withContext($context);
147 148
         }
148 149
 
Please login to merge, or discard this patch.
src/Validation/Checker/EntityChecker.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     public function exists($value, string $role, ?string $field = null): bool
39 39
     {
40 40
         $repository = $this->orm->getRepository($role);
41
-        if ($field === null) {
41
+        if ($field === null){
42 42
             return $repository->findByPK($value) !== null;
43 43
         }
44 44
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         $values = $this->withValues($withFields);
58 58
         $values[$field] = $value;
59 59
 
60
-        if ($this->isProvidedByContext($role, $values)) {
60
+        if ($this->isProvidedByContext($role, $values)){
61 61
             return true;
62 62
         }
63 63
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
     private function withValues(array $fields): array
72 72
     {
73 73
         $values = [];
74
-        foreach ($fields as $field) {
75
-            if ($this->getValidator()->hasValue($field)) {
74
+        foreach ($fields as $field){
75
+            if ($this->getValidator()->hasValue($field)){
76 76
                 $values[$field] = $this->getValidator()->getValue($field);
77 77
             }
78 78
         }
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
     private function isProvidedByContext(string $role, array $values): bool
89 89
     {
90 90
         $entity = $this->getValidator()->getContext();
91
-        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) {
91
+        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)){
92 92
             return false;
93 93
         }
94 94
 
95 95
         $extract = $this->orm->getMapper($role)->extract($entity);
96
-        foreach ($values as $field => $value) {
97
-            if (!isset($extract[$field]) || $extract[$field] !== $value) {
96
+        foreach ($values as $field => $value){
97
+            if (!isset($extract[$field]) || $extract[$field] !== $value){
98 98
                 return false;
99 99
             }
100 100
         }
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
38 38
     public function exists($value, string $role, ?string $field = null): bool
39 39
     {
40 40
         $repository = $this->orm->getRepository($role);
41
-        if ($field === null) {
41
+        if ($field === null)
42
+        {
42 43
             return $repository->findByPK($value) !== null;
43 44
         }
44 45
 
@@ -57,7 +58,8 @@  discard block
 block discarded – undo
57 58
         $values = $this->withValues($withFields);
58 59
         $values[$field] = $value;
59 60
 
60
-        if ($this->isProvidedByContext($role, $values)) {
61
+        if ($this->isProvidedByContext($role, $values))
62
+        {
61 63
             return true;
62 64
         }
63 65
 
@@ -71,8 +73,10 @@  discard block
 block discarded – undo
71 73
     private function withValues(array $fields): array
72 74
     {
73 75
         $values = [];
74
-        foreach ($fields as $field) {
75
-            if ($this->getValidator()->hasValue($field)) {
76
+        foreach ($fields as $field)
77
+        {
78
+            if ($this->getValidator()->hasValue($field))
79
+            {
76 80
                 $values[$field] = $this->getValidator()->getValue($field);
77 81
             }
78 82
         }
@@ -88,13 +92,16 @@  discard block
 block discarded – undo
88 92
     private function isProvidedByContext(string $role, array $values): bool
89 93
     {
90 94
         $entity = $this->getValidator()->getContext();
91
-        if (!is_object($entity) || !$this->orm->getHeap()->has($entity)) {
95
+        if (!is_object($entity) || !$this->orm->getHeap()->has($entity))
96
+        {
92 97
             return false;
93 98
         }
94 99
 
95 100
         $extract = $this->orm->getMapper($role)->extract($entity);
96
-        foreach ($values as $field => $value) {
97
-            if (!isset($extract[$field]) || $extract[$field] !== $value) {
101
+        foreach ($values as $field => $value)
102
+        {
103
+            if (!isset($extract[$field]) || $extract[$field] !== $value)
104
+            {
98 105
                 return false;
99 106
             }
100 107
         }
Please login to merge, or discard this patch.
src/Domain/FilterInterceptor.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
53
+            if (isset($parameters[$parameter])){
54 54
                 continue;
55 55
             }
56 56
 
57 57
             /** @var FilterInterface $filter */
58 58
             $filter = $this->container->get($filterClass);
59
-            if (isset($parameters['@context'])) {
59
+            if (isset($parameters['@context'])){
60 60
                 $filter->setContext($parameters['@context']);
61 61
             }
62 62
 
63
-            if (!$filter->isValid()) {
63
+            if (!$filter->isValid()){
64 64
                 return $this->renderInvalid($filter);
65 65
             }
66 66
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     protected function renderInvalid(FilterInterface $filter)
80 80
     {
81
-        switch ($this->strategy) {
81
+        switch ($this->strategy){
82 82
             case self::STRATEGY_JSON_RESPONSE:
83 83
                 return [
84 84
                     'status' => 400,
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
     private function getDeclaredFilters(string $controller, string $action): array
98 98
     {
99 99
         $key = sprintf('%s:%s', $controller, $action);
100
-        if (array_key_exists($key, $this->cache)) {
100
+        if (array_key_exists($key, $this->cache)){
101 101
             return $this->cache[$key];
102 102
         }
103 103
 
104 104
         $this->cache[$key] = [];
105
-        try {
105
+        try{
106 106
             $method = new \ReflectionMethod($controller, $action);
107
-        } catch (\ReflectionException $e) {
107
+        }catch (\ReflectionException $e){
108 108
             return [];
109 109
         }
110 110
 
111
-        foreach ($method->getParameters() as $parameter) {
112
-            if ($parameter->getClass() === null) {
111
+        foreach ($method->getParameters() as $parameter){
112
+            if ($parameter->getClass() === null){
113 113
                 continue;
114 114
             }
115 115
 
116
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
116
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class)){
117 117
                 $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName();
118 118
             }
119 119
         }
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -49,18 +49,22 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
53
+        {
54
+            if (isset($parameters[$parameter]))
55
+            {
54 56
                 continue;
55 57
             }
56 58
 
57 59
             /** @var FilterInterface $filter */
58 60
             $filter = $this->container->get($filterClass);
59
-            if (isset($parameters['@context'])) {
61
+            if (isset($parameters['@context']))
62
+            {
60 63
                 $filter->setContext($parameters['@context']);
61 64
             }
62 65
 
63
-            if (!$filter->isValid()) {
66
+            if (!$filter->isValid())
67
+            {
64 68
                 return $this->renderInvalid($filter);
65 69
             }
66 70
 
@@ -78,7 +82,8 @@  discard block
 block discarded – undo
78 82
      */
79 83
     protected function renderInvalid(FilterInterface $filter)
80 84
     {
81
-        switch ($this->strategy) {
85
+        switch ($this->strategy)
86
+        {
82 87
             case self::STRATEGY_JSON_RESPONSE:
83 88
                 return [
84 89
                     'status' => 400,
@@ -97,23 +102,30 @@  discard block
 block discarded – undo
97 102
     private function getDeclaredFilters(string $controller, string $action): array
98 103
     {
99 104
         $key = sprintf('%s:%s', $controller, $action);
100
-        if (array_key_exists($key, $this->cache)) {
105
+        if (array_key_exists($key, $this->cache))
106
+        {
101 107
             return $this->cache[$key];
102 108
         }
103 109
 
104 110
         $this->cache[$key] = [];
105
-        try {
111
+        try
112
+        {
106 113
             $method = new \ReflectionMethod($controller, $action);
107
-        } catch (\ReflectionException $e) {
114
+        }
115
+        catch (\ReflectionException $e)
116
+        {
108 117
             return [];
109 118
         }
110 119
 
111
-        foreach ($method->getParameters() as $parameter) {
112
-            if ($parameter->getClass() === null) {
120
+        foreach ($method->getParameters() as $parameter)
121
+        {
122
+            if ($parameter->getClass() === null)
123
+            {
113 124
                 continue;
114 125
             }
115 126
 
116
-            if ($parameter->getClass()->implementsInterface(FilterInterface::class)) {
127
+            if ($parameter->getClass()->implementsInterface(FilterInterface::class))
128
+            {
117 129
                 $this->cache[$key][$parameter->getName()] = $parameter->getClass()->getName();
118 130
             }
119 131
         }
Please login to merge, or discard this patch.
src/Domain/CycleInterceptor.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role){
50 50
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
51
+            if ($value === null){
52 52
                 throw new ControllerException(
53 53
                     "Entity `{$parameter}` can not be found",
54 54
                     ControllerException::NOT_FOUND
55 55
                 );
56 56
             }
57 57
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
58
+            if (is_object($value)){
59
+                if ($this->orm->getHeap()->has($value)){
60 60
                     $contextCandidates[] = $value;
61 61
                 }
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             }
66 66
 
67 67
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
68
+            if ($entity === null){
69 69
                 throw new ControllerException(
70 70
                     "Entity `{$parameter}` can not be found",
71 71
                     ControllerException::NOT_FOUND
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
             }
74 74
 
75 75
             $parameters[$parameter] = $entity;
76
-            if ($this->orm->getHeap()->has($value)) {
76
+            if ($this->orm->getHeap()->has($value)){
77 77
                 $contextCandidates[] = $value;
78 78
             }
79 79
         }
80 80
 
81
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
81
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1){
82 82
             $parameters['@context'] = current($contextCandidates);
83 83
         }
84 84
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
95 95
     {
96
-        if (!$useDefault) {
96
+        if (!$useDefault){
97 97
             return $parameters[$role] ?? null;
98 98
         }
99 99
 
@@ -118,23 +118,23 @@  discard block
 block discarded – undo
118 118
     private function getDeclaredEntities(string $controller, string $action): array
119 119
     {
120 120
         $key = sprintf('%s:%s', $controller, $action);
121
-        if (array_key_exists($key, $this->cache)) {
121
+        if (array_key_exists($key, $this->cache)){
122 122
             return $this->cache[$key];
123 123
         }
124 124
 
125 125
         $this->cache[$key] = [];
126
-        try {
126
+        try{
127 127
             $method = new \ReflectionMethod($controller, $action);
128
-        } catch (\ReflectionException $e) {
128
+        }catch (\ReflectionException $e){
129 129
             return [];
130 130
         }
131 131
 
132
-        foreach ($method->getParameters() as $parameter) {
133
-            if ($parameter->getClass() === null) {
132
+        foreach ($method->getParameters() as $parameter){
133
+            if ($parameter->getClass() === null){
134 134
                 continue;
135 135
             }
136 136
 
137
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
137
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())){
138 138
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName());
139 139
             }
140 140
         }
Please login to merge, or discard this patch.
Braces   +29 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,17 +46,21 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role)
50
+        {
50 51
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
52
+            if ($value === null)
53
+            {
52 54
                 throw new ControllerException(
53 55
                     "Entity `{$parameter}` can not be found",
54 56
                     ControllerException::NOT_FOUND
55 57
                 );
56 58
             }
57 59
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
60
+            if (is_object($value))
61
+            {
62
+                if ($this->orm->getHeap()->has($value))
63
+                {
60 64
                     $contextCandidates[] = $value;
61 65
                 }
62 66
 
@@ -65,7 +69,8 @@  discard block
 block discarded – undo
65 69
             }
66 70
 
67 71
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
72
+            if ($entity === null)
73
+            {
69 74
                 throw new ControllerException(
70 75
                     "Entity `{$parameter}` can not be found",
71 76
                     ControllerException::NOT_FOUND
@@ -73,12 +78,14 @@  discard block
 block discarded – undo
73 78
             }
74 79
 
75 80
             $parameters[$parameter] = $entity;
76
-            if ($this->orm->getHeap()->has($value)) {
81
+            if ($this->orm->getHeap()->has($value))
82
+            {
77 83
                 $contextCandidates[] = $value;
78 84
             }
79 85
         }
80 86
 
81
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
87
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1)
88
+        {
82 89
             $parameters['@context'] = current($contextCandidates);
83 90
         }
84 91
 
@@ -93,7 +100,8 @@  discard block
 block discarded – undo
93 100
      */
94 101
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
95 102
     {
96
-        if (!$useDefault) {
103
+        if (!$useDefault)
104
+        {
97 105
             return $parameters[$role] ?? null;
98 106
         }
99 107
 
@@ -118,23 +126,30 @@  discard block
 block discarded – undo
118 126
     private function getDeclaredEntities(string $controller, string $action): array
119 127
     {
120 128
         $key = sprintf('%s:%s', $controller, $action);
121
-        if (array_key_exists($key, $this->cache)) {
129
+        if (array_key_exists($key, $this->cache))
130
+        {
122 131
             return $this->cache[$key];
123 132
         }
124 133
 
125 134
         $this->cache[$key] = [];
126
-        try {
135
+        try
136
+        {
127 137
             $method = new \ReflectionMethod($controller, $action);
128
-        } catch (\ReflectionException $e) {
138
+        }
139
+        catch (\ReflectionException $e)
140
+        {
129 141
             return [];
130 142
         }
131 143
 
132
-        foreach ($method->getParameters() as $parameter) {
133
-            if ($parameter->getClass() === null) {
144
+        foreach ($method->getParameters() as $parameter)
145
+        {
146
+            if ($parameter->getClass() === null)
147
+            {
134 148
                 continue;
135 149
             }
136 150
 
137
-            if ($this->orm->getSchema()->defines($parameter->getClass()->getName())) {
151
+            if ($this->orm->getSchema()->defines($parameter->getClass()->getName()))
152
+            {
138 153
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($parameter->getClass()->getName());
139 154
             }
140 155
         }
Please login to merge, or discard this patch.