Completed
Push — master ( d54351...6ce5d4 )
by Rafael
03:34
created

MapMatcher::match()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
/**
4
 * LICENSE: This file is subject to the terms and conditions defined in
5
 * file 'LICENSE', which is part of this source code package.
6
 *
7
 * @copyright 2016 Copyright(c) - All rights reserved.
8
 */
9
10
namespace Rafrsr\LibArray2Object\PropertyMatcher;
11
12
/**
13
 * Class MapMatcher
14
 */
15
class MapMatcher implements PropertyMatcherInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $map;
21
22
    /**
23
     * MapMatcher constructor.
24
     *
25
     * @param array $map
26
     */
27
    public function __construct(array $map)
28
    {
29
        $this->map = $map;
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function match(\ReflectionProperty $property, $givenName)
36
    {
37
        if (array_key_exists($property->getName(), $this->map)) {
38
            return ($this->map[$property->getName()] === $givenName);
39
        }
40
41
        return false;
42
    }
43
}