Code Duplication    Length = 15-17 lines in 3 locations

src/Attributes.php 3 locations

@@ 81-95 (lines=15) @@
78
     *
79
     * @return $this
80
     */
81
    public function append($key, $value = null)
82
    {
83
        $this->storage += array(
84
            $key => new Attribute(
85
                $key,
86
                $this->ensureString($value)
87
            )
88
        );
89
90
        foreach ($this->normalizeValue($value) as $value_item) {
91
            $this->storage[$key]->append($value_item);
92
        }
93
94
        return $this;
95
    }
96
97
    /**
98
     * Remove a value from a specific attribute.
@@ 166-180 (lines=15) @@
163
     *
164
     * @return $this
165
     */
166
    public function replace($key, $value, $replacement)
167
    {
168
        $this->storage += array(
169
            $key => new Attribute(
170
                $key,
171
                $this->ensureString($value)
172
            )
173
        );
174
175
        foreach ($this->normalizeValue($replacement) as $replacement_value) {
176
            $this->storage[$key]->replace($value, $replacement_value);
177
        }
178
179
        return $this;
180
    }
181
182
    /**
183
     * Merge attributes.
@@ 190-206 (lines=17) @@
187
     *
188
     * @return $this
189
     */
190
    public function merge(array $data = array())
191
    {
192
        foreach ($data as $key => $value) {
193
            $this->storage += array(
194
                $key => new Attribute(
195
                    $key,
196
                    $this->ensureString($value)
197
                )
198
            );
199
200
            $this->storage[$key]->merge(
201
                $this->normalizeValue($value)
202
            );
203
        }
204
205
        return $this;
206
    }
207
208
    /**
209
     * Check if an attribute exists and if a value if provided check it as well.