VisibleAs::createFailMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
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\TheMethod\Be;
12
13
use Gabrieljmj\Should\Assert\TheMethod\AbstractMethodAssert;
14
use Gabrieljmj\Should\Options\Visibility;
15
use Gabrieljmj\Should\Exception\InvalidVisibilityTypeException;
16
17
class VisibleAs extends AbstractMethodAssert
18
{
19
    use \Gabrieljmj\Should\Assert\Traits\VisibilityAssertTrait;
20
21
    /**
22
     * Visibility (public, private, protected)
23
     * Use the constants of \Gabrieljmj\Should\Options\Visibility
24
     *
25
     * @var integer
26
     */
27
    private $visibility;
28
29
    /**
30
     * @param string|object $class
31
     * @param string        $method
32
     * @param integer       $visibility \Gabrieljmj\Should\Options\Visibility consts
33
     */
34
    public function __construct($class, $method, $visibility)
35
    {
36
        parent::__construct($class, $method);
37
        $this->visibility = $visibility;
38
    }
39
40
    /**
41
     * Executes the assert
42
     *
43
     * @return boolean
44
     */
45
    public function execute()
46
    {
47
        $ref = new \ReflectionMethod($this->class, $this->method);
48
49
        return $this->check($ref, $this->visibility);
50
    }
51
52
    /**
53
     * Returns the assert description
54
     *
55
     * @return string
56
     */
57
    public function getDescription()
58
    {
59
        return 'Tests if the visibility of a method is the same as the determined.';
60
    }
61
62
    /**
63
     * Creates the fail message
64
     *
65
     * @return string
66
     */
67
    protected function createFailMessage()
68
    {
69
        $class = $this->classToStr($this->class);
70
        return 'The arguments of the method ' . $class . '::' . $this->method . ' are incorrect';
71
    }
72
}