This class seems to be duplicated in 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...
16
{
17
public function __construct(AttributeSet $attributes = null, ElementSet $children = null)
18
{
19
$this->attributes = $attributes ?? new AttributeSet();
20
$this->children = $children ?? new ElementSet();
21
$this->tag = new Standard('summary', $attributes, $children);
22
}
23
24
public function withAttribute(string $name, string $value = null): Summary
The expression $value of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
27
$attribute = new StandardAttribute($name, $value);
28
} else {
29
$attribute = new BooleanAttribute($name);
30
}
31
32
return new Summary($this->attributes->add($attribute), $this->children);
33
}
34
35
public function withChild(ElementInterface $element): Summary
36
{
37
return new Summary($this->attributes, $this->children->add($element));
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.