IsConstantDefinedConstraint::toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace BuildR\TestTools\Asserts;
2
3
/**
4
 * Custom PHPUnit Constraint that check whenever a constant is defined.
5
 *
6
 * BuildR PHP Framework
7
 *
8
 * @author Zoltán Borsos <[email protected]>
9
 * @package TestTools
10
 * @subpackage Asserts
11
 *
12
 * @copyright    Copyright 2016, Zoltán Borsos.
13
 * @license      https://github.com/BuildrPHP/Test-Tools/blob/master/LICENSE.md
14
 * @link         https://github.com/BuildrPHP/Test-Tools
15
 */
16
class IsConstantDefinedConstraint extends \PHPUnit_Framework_Constraint {
17
18
    /**
19
     * {@inheritDoc}
20
     */
21 3 View Code Duplication
    protected function matches($other) {
22 3
        if(!is_string($other)) {
23 1
            return FALSE;
24
        }
25
26 2
        if(is_string($other) && defined($other)) {
27 1
            return TRUE;
28
        }
29
30 1
        return FALSE;
31
    }
32
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 2
    public function toString() {
38 2
        return 'constant is defined';
39
    }
40
41
}
42