GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FieldMapperTrait   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 62
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A registerFieldMappers() 0 6 2
A registerFieldMapper() 0 8 2
A getFieldMapper() 0 8 2
A getFieldMappers() 0 4 1
A mapperRegisteredForField() 0 4 1
1
<?php
2
/**
3
 * Mapper for mapping data between raw input and Data classes
4
 *
5
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
8
 * @category    PHPExif
9
 * @package     Common
10
 * @codeCoverageIgnore
11
 */
12
13
namespace PHPExif\Common\Mapper;
14
15
use PHPExif\Common\Exception\Mapper\MapperNotRegisteredException;
16
17
/**
18
 * Mapper
19
 *
20
 * @category    PHPExif
21
 * @package     Exif
22
 */
23
trait FieldMapperTrait
24
{
25
    /**
26
     * @var FieldMapper[]
27
     */
28
    private $fieldMappers = array();
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function registerFieldMappers(array $fieldMappers)
34
    {
35
        foreach ($fieldMappers as $fieldMapper) {
36
            $this->registerFieldMapper($fieldMapper);
37
        }
38
    }
39
40
    /**
41
     * Registers given FieldMapper instance
42
     * Allows overwriting an already existing mapper for a given field
43
     *
44
     * @param FieldMapper $fieldMapper
45
     *
46
     * @return void
47
     */
48
    public function registerFieldMapper(FieldMapper $fieldMapper)
49
    {
50
        $targetFields = $fieldMapper->getSupportedFields();
51
52
        foreach ($targetFields as $fieldName) {
53
            $this->fieldMappers[$fieldName] = $fieldMapper;
54
        }
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     */
60
    public function getFieldMapper($field)
61
    {
62
        if (!$this->mapperRegisteredForField($field)) {
63
            throw MapperNotRegisteredException::forField($field);
64
        }
65
66
        return $this->fieldMappers[$field];
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    public function getFieldMappers()
73
    {
74
        return $this->fieldMappers;
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80
    public function mapperRegisteredForField($field)
81
    {
82
        return array_key_exists($field, $this->fieldMappers);
83
    }
84
}
85