Injection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 60
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFromContract() 0 4 1
A getJs() 0 4 1
A setJs() 0 4 1
A getType() 0 4 1
A jsonSerialize() 0 6 1
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
}