Code Duplication    Length = 9-9 lines in 2 locations

math/Vector.php 2 locations

@@ 183-191 (lines=9) @@
180
            foreach ($this->components as $i => $component) {
181
                $result[$i] = $component + $that->components[$i];
182
            }
183
        } elseif (is_numeric($that)) {
184
            // We're accepting all numeric values but will be casting to a float, so be aware of potential
185
            // precision loss.
186
            $that = (float) $that;
187
188
            foreach ($this->components as $i => $component) {
189
                $result[$i] = $component + $that;
190
            }
191
        } else {
192
            throw new \InvalidArgumentException('Unknown type to add given - can only add other Vectors or numbers to Vectors.');
193
        }
194
@@ 595-603 (lines=9) @@
592
            foreach ($this->components as $i => $component) {
593
                $result[$i] = $component - $that->components[$i];
594
            }
595
        } elseif (is_numeric($that)) {
596
            // We're accepting all numeric values but will be casting to a float, so be aware of potential
597
            // precision loss.
598
            $that = (float) $that;
599
600
            foreach ($this->components as $i => $component) {
601
                $result[$i] = $component - $that;
602
            }
603
        } else {
604
            throw new \InvalidArgumentException('Expected a Vector or a number to subtract, got ['.diagnostics\Debug::getTypeName($that).'] instead.');
605
        }
606