DataSourceAsserter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setWith() 0 14 3
A isDataSource() 0 4 1
A valueIsSet() 0 4 1
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Core\Collections\Tests\Asserters;
12
13
use Cubiche\Core\Collections\DataSource\DataSourceInterface;
14
use mageekguy\atoum\asserters\phpObject as ObjectAsserter;
15
16
/**
17
 * DataSourceAsserter class.
18
 *
19
 * @author Ivannis Suárez Jerez <[email protected]>
20
 */
21
class DataSourceAsserter extends ObjectAsserter
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function setWith($value, $checkType = true)
27
    {
28
        parent::setWith($value, $checkType);
29
30
        if ($checkType === true) {
31
            if (self::isDataSource($this->value) === false) {
32
                $this->fail($this->getLocale()->_('%s is not an datasource', $this));
33
            } else {
34
                $this->pass();
35
            }
36
        }
37
38
        return $this;
39
    }
40
41
    /**
42
     * @param $value
43
     *
44
     * @return bool
45
     */
46
    protected static function isDataSource($value)
47
    {
48
        return $value instanceof DataSourceInterface;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    protected function valueIsSet($message = 'DataSource is undefined')
55
    {
56
        return parent::valueIsSet($message);
57
    }
58
}
59