Equal::createFailMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * ShouldPHP
4
 *
5
 * @author  Gabriel Jacinto <[email protected]>
6
 * @status  dev
7
 * @link    https://github.com/GabrielJMJ/ShouldPHP
8
 * @license MIT
9
 */
10
 
11
namespace Gabrieljmj\Should\Assert\TheClass\Be;
12
13
use Gabrieljmj\Should\Assert\TheClass\AbstractClassAssert;
14
15
class Equal extends AbstractClassAssert
16
{
17
    /**
18
     * @var object
19
     */
20
    private $arg2;
21
    
22
    /**
23
     * @param object $class
24
     * @param object $arg2
25
     */
26
    public function __construct($class, $arg2)
27
    {
28
        if (!is_object($class) || !is_object($arg2)) {
29
            throw new \InvalidArgumentException('Both arguments must be object');
30
        }
31
        
32
        parent::__construct($class);
33
        $this->arg2 = $arg2;
34
    }
35
36
    /**
37
     * Returns the assert description
38
     *
39
     * @return string
40
     */
41
    public function getDescription()
42
    {
43
        return 'Tests if an instance of some class is equal other';
44
    }
45
46
    /**
47
     * Creates the fail message
48
     *
49
     * @return string
50
     */
51
    protected function createFailMessage()
52
    {
53
        $class = $this->classToStr($this->class);
54
        $arg2 = $this->classToStr($this->arg2);
55
        return 'The instance of ' . $class . ' is not equal to the another instance of ' . $arg2;
56
    }
57
58
    /**
59
     * Executes the assert
60
     *
61
     * @return boolean
62
     */
63
    public function execute()
64
    {
65
        return $this->class == $this->arg2;
66
    }
67
}