Completed
Push — master ( c32bd7...f916e0 )
by Hannes
02:12
created

Example::getCodeBlock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace hanneskod\readmetester;
4
5
/**
6
 * Wrapper around a block of code and it's expectations
7
 */
8
class Example
9
{
10
    /**
11
     * @var string Name of this example
12
     */
13
    private $name;
14
15
    /**
16
     * @var string Example code
17
     */
18
    private $code = '';
19
20
    /**
21
     * @var Expectation\ExpectationInterface[] List of expectations
22
     */
23
    private $expectations = array();
24
25
    /**
26
     * Set name of example
27
     *
28
     * @param string $name
29
     */
30
    public function __construct($name)
31
    {
32
        $this->name = $name;
33
    }
34
35
    /**
36
     * Get name of example
37
     *
38
     * @return string
39
     */
40
    public function getName()
41
    {
42
        return $this->name;
43
    }
44
45
    /**
46
     * Add line to example code
47
     *
48
     * @param  string $line
49
     * @return null
50
     */
51
    public function addLine($line)
52
    {
53
        $this->code .= $line;
54
    }
55
56
    /**
57
     * Get example code block
58
     *
59
     * @return CodeBlock
60
     */
61
    public function getCodeBlock()
62
    {
63
        return new CodeBlock($this->code);
64
    }
65
66
    /**
67
     * Add expectation to example
68
     *
69
     * @param  Expectation\ExpectationInterface $expectation
70
     * @return null
71
     */
72
    public function addExpectation(Expectation\ExpectationInterface $expectation)
73
    {
74
        $this->expectations[] = $expectation;
75
    }
76
77
    /**
78
     * Get registered expectations
79
     *
80
     * @return Expectation\ExpectationInterface[]
81
     */
82
    public function getExpectations()
83
    {
84
        return $this->expectations;
85
    }
86
}
87