Passed
Push — master ( 661b73...ccb1dd )
by Sebastian
08:54 queued 05:17
created

IsUncertainDate   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 9 4
A __construct() 0 4 1
1
<?php
2
/*
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
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
 */
3 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
21
class IsUncertainDate implements ConstraintInterface
22
{
23
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
24
     * @var string
25
     */
26
    private $varName;
0 ignored issues
show
Coding Style introduced by
Private member variable "varName" must be prefixed with an underscore
Loading history...
27
28
29
    private $match;
0 ignored issues
show
Coding Style introduced by
Private member variable "match" must be prefixed with an underscore
Loading history...
30
31 7
    public function __construct($value, $match = "all")
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
32
    {
33 7
        $this->varName = $value;
34 7
        $this->match = $match;
35 7
    }
36
37
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $value should have a doc-comment as per coding-style.
Loading history...
38
     * @param $value
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter name
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
39
     * @param int|null $citationNumber
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
40
     * @return bool
1 ignored issue
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
41
     */
42 7
    public function validate($value, $citationNumber = null)
43
    {
44 7
        if (!empty($value->{$this->varName})) {
45 5
            if (isset($value->{$this->varName}->{'circa'}) && !empty($value->{$this->varName})) {
46 1
                return true;
47
            }
48
        }
49
50 7
        return false;
51
    }
52
}