Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is
duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
22
$attributes = $attributes[0];
23
24
if (!isset($attributes['alias'])) {
25
throw new \InvalidArgumentException(sprintf(
26
'Description schema extension "%s" has no "alias" attribute in its tag',
27
$extensionId
28
));
29
}
30
31
$alias = $attributes['alias'];
32
33
$extensionRefs[$alias] = new Reference($extensionId);
The expression $diff of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an
empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using empty(..) or !empty(...) instead.
Loading history...
40
throw new \InvalidArgumentException(sprintf(
41
'Unknown schema extension(s) "%s" specified. Known extensions: "%s"',
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.