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

IsUncertainDate   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A validate() 0 10 3
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
}