Completed
Push — master ( c434f2...7ac5be )
by Sebastian
03:19
created

IsUncertainDate::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
/**
3
 * citeproc-php
4
 *
5
 * @link        http://github.com/seboettg/citeproc-php for the source repository
6
 * @copyright   Copyright (c) 2016 Sebastian Böttger.
7
 * @license     https://opensource.org/licenses/MIT
8
 */
9
10
namespace Seboettg\CiteProc\Constraint;
11
12
13
/**
14
 * Class isUncertainDate
15
 * Tests whether the given date variables contain approximate dates.
16
 *
17
 * @package Seboettg\CiteProc\Choose\Constraint
18
 *
19
 * @author Sebastian Böttger <[email protected]>
20
 */
21
class IsUncertainDate implements ConstraintInterface
22
{
23
24
    private $varName;
25
26
    private $match;
27
28
    public function __construct($value, $match)
29
    {
30
        $this->varName = $value;
31
        $this->match = $match;
32
    }
33
34
    public function validate($value)
35
    {
36
        $value = $value->{$this->varName};
37
38
        if (is_array($value) && array_key_exists('circa', $value)) {
39
            return true;
40
        }
41
42
        return false;
43
    }
44
}