Code Duplication    Length = 10-11 lines in 3 locations

src/TypedListTrait.php 2 locations

@@ 129-138 (lines=10) @@
126
        $this->compositeVector = new Vector($items);
127
    }
128
129
    private function assertItemIndex($index): void
130
    {
131
        if (!is_int($index)) {
132
            throw new InvalidArgumentException(sprintf(
133
                'Invalid item key given to %s. Expected int but was given %s.',
134
                static::CLASS,
135
                is_object($index) ? get_class($index) : @gettype($index)
136
            ));
137
        }
138
    }
139
140
    private function assertItemType($item): void
141
    {
@@ 140-150 (lines=11) @@
137
        }
138
    }
139
140
    private function assertItemType($item): void
141
    {
142
        if (!is_a($item, $this->itemFqcn)) {
143
            throw new InvalidArgumentException(sprintf(
144
                'Invalid item type given to %s. Expected %s but was given %s.',
145
                static::CLASS,
146
                $this->itemFqcn,
147
                is_object($item) ? get_class($item) : @gettype($item)
148
            ));
149
        }
150
    }
151
152
    private function __clone()
153
    {

src/TypedMapTrait.php 1 location

@@ 89-98 (lines=10) @@
86
        $this->compositeMap = new Map($items);
87
    }
88
89
    private function assertItemKey($key): void
90
    {
91
        if (!is_string($key)) {
92
            throw new InvalidArgumentException(sprintf(
93
                'Invalid item key given to %s. Expected string but was given %s.',
94
                static::CLASS,
95
                is_object($key) ? get_class($key) : @gettype($key)
96
            ));
97
        }
98
    }
99
100
    private function assertItemType($item): void
101
    {