AbstractTypedMap   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A offsetSet() 0 16 3
1
<?php
2
3
/**
4
 * This file is part of the ramsey/collection library
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10
 * @license http://opensource.org/licenses/MIT MIT
11
 * @link https://benramsey.com/projects/ramsey-collection/ Documentation
12
 * @link https://packagist.org/packages/ramsey/collection Packagist
13
 * @link https://github.com/ramsey/collection GitHub
14
 */
15
16
namespace Ramsey\Collection\Map;
17
18
use Ramsey\Collection\Tool\TypeTrait;
19
use Ramsey\Collection\Tool\ValueToStringTrait;
20
21
/**
22
 * This class provides an implementation of the TypedMapInterface, to
23
 * minimize the effort required to implement this interface
24
 */
25
abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface
26
{
27
    use TypeTrait;
28
    use ValueToStringTrait;
29
30
    public function offsetSet($offset, $value)
31
    {
32
        if (false === $this->checkType($this->getKeyType(), $offset)) {
33
            throw new \InvalidArgumentException(
34
                'Key must be of type ' . $this->getKeyType() . '; key is '
35
                . $this->toolValueToString($offset)
36
            );
37
        }
38
        if (false === $this->checkType($this->getValueType(), $value)) {
39
            throw new \InvalidArgumentException(
40
                'Value must be of type ' . $this->getValueType() . '; value is '
41
                . $this->toolValueToString($value)
42
            );
43
        }
44
        parent::offsetSet($offset, $value);
45
    }
46
}
47