Injection::setJs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Meare\Juggler\Imposter\Stub;
4
5
6
use Meare\Juggler\Imposter\Stub\Predicate\IPredicate;
7
use Meare\Juggler\Imposter\Stub\Response\IResponse;
8
9
class Injection implements IResponse, IPredicate
10
{
11
    /**
12
     * @var string
13
     */
14
    private $type = self::TYPE_INJECT;
15
16
    /**
17
     * @var string
18
     */
19
    private $js;
20
21 11
    public function __construct($js)
22
    {
23 11
        $this->js = $js;
24 11
    }
25
26
    /**
27
     * @param string $js Contract is JS string injection in case of 'inject'
28
     * @return Injection
29
     */
30 3
    public static function createFromContract($js)
31
    {
32 3
        return new self($js);
33
    }
34
35
    /**
36
     * @return string
37
     */
38 2
    public function getJs()
39
    {
40 2
        return $this->js;
41
    }
42
43
    /**
44
     * @param string $js
45
     */
46 1
    public function setJs($js)
47
    {
48 1
        $this->js = $js;
49 1
    }
50
51
    /**
52
     * @return array
53
     */
54 3
    public function jsonSerialize()
55
    {
56
        return [
57 3
            IResponse::TYPE_INJECT => $this->js,
58 3
        ];
59
    }
60
61
    /**
62
     * @return string
63
     */
64 2
    public function getType()
65
    {
66 2
        return $this->type;
67
    }
68
}