Conditions | 8 |
Paths | 16 |
Total Lines | 72 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
109 | protected function setAttributesNS(array $attributes): void |
||
110 | { |
||
111 | Assert::allIsInstanceOf( |
||
112 | $attributes, |
||
113 | Attribute::class, |
||
114 | 'Arbitrary XML attributes can only be an instance of Attribute.', |
||
115 | ); |
||
116 | $namespace = $this->getAttributeNamespace(); |
||
117 | |||
118 | // Validate namespace value |
||
119 | if (!is_array($namespace)) { |
||
120 | // Must be one of the predefined values |
||
121 | Assert::oneOf($namespace, C::XS_ANY_NS); |
||
122 | } else { |
||
123 | // Array must be non-empty and cannot contain ##any or ##other |
||
124 | Assert::notEmpty($namespace); |
||
125 | Assert::allNotSame($namespace, C::XS_ANY_NS_ANY); |
||
126 | Assert::allNotSame($namespace, C::XS_ANY_NS_OTHER); |
||
127 | } |
||
128 | |||
129 | // Get namespaces for all attributes |
||
130 | $actual_namespaces = array_map( |
||
131 | /** |
||
132 | * @param \SimpleSAML\XML\Attribute $elt |
||
133 | * @return string|null |
||
134 | */ |
||
135 | function (Attribute $attr) { |
||
136 | return $attr->getNamespaceURI(); |
||
137 | }, |
||
138 | $attributes, |
||
139 | ); |
||
140 | |||
141 | if ($namespace === C::XS_ANY_NS_LOCAL) { |
||
142 | // If ##local then all namespaces must be null |
||
143 | Assert::allNull($actual_namespaces); |
||
144 | } elseif (is_array($namespace)) { |
||
145 | // Make a local copy of the property that we can edit |
||
146 | $allowed_namespaces = $namespace; |
||
147 | |||
148 | // Replace the ##targetedNamespace with the actual namespace |
||
149 | if (($key = array_search(C::XS_ANY_NS_TARGET, $allowed_namespaces)) !== false) { |
||
150 | $allowed_namespaces[$key] = static::NS; |
||
1 ignored issue
–
show
|
|||
151 | } |
||
152 | |||
153 | // Replace the ##local with null |
||
154 | if (($key = array_search(C::XS_ANY_NS_LOCAL, $allowed_namespaces)) !== false) { |
||
155 | $allowed_namespaces[$key] = null; |
||
156 | } |
||
157 | |||
158 | $diff = array_diff($actual_namespaces, $allowed_namespaces); |
||
159 | Assert::isEmpty( |
||
160 | $diff, |
||
161 | sprintf( |
||
162 | 'Attributes from namespaces [ %s ] are not allowed inside a %s element.', |
||
163 | rtrim(implode(', ', $diff)), |
||
164 | static::NS, |
||
165 | ), |
||
166 | ); |
||
167 | } else { |
||
168 | // All elements must be namespaced, ergo non-null |
||
169 | Assert::allNotNull($actual_namespaces); |
||
170 | |||
171 | if ($namespace === C::XS_ANY_NS_OTHER) { |
||
172 | // Must be any namespace other than the parent element |
||
173 | Assert::allNotSame($actual_namespaces, static::NS); |
||
174 | } elseif ($namespace === C::XS_ANY_NS_TARGET) { |
||
175 | // Must be the same namespace as the one of the parent element |
||
176 | Assert::allSame($actual_namespaces, static::NS); |
||
177 | } |
||
178 | } |
||
179 | |||
180 | $this->namespacedAttributes = $attributes; |
||
181 | } |
||
200 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths