RuntimeFunction::getObjectSpec()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
/*
4
 * This file is part of the pinepain/js-sandbox PHP library.
5
 *
6
 * Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7
 *
8
 * Licensed under the MIT license: http://opensource.org/licenses/MIT
9
 *
10
 * For the full copyright and license information, please view the
11
 * LICENSE file that was distributed with this source or visit
12
 * http://opensource.org/licenses/MIT
13
 */
14
15
16
namespace Pinepain\JsSandbox\Wrappers\Runtime;
17
18
19
use Pinepain\JsSandbox\Specs\FunctionSpecInterface;
20
use Pinepain\JsSandbox\Specs\ObjectSpecInterface;
21
22
23
class RuntimeFunction implements RuntimeFunctionInterface
24
{
25
    /**
26
     * @var string
27
     */
28
    private $name;
29
    /**
30
     * @var callable
31
     */
32
    private $callback;
33
    /**
34
     * @var FunctionSpecInterface
35
     */
36
    private $spec;
37
    /**
38
     * @var null|object
39
     */
40
    private $object;
41
    /**
42
     * @var null|ObjectSpecInterface
43
     */
44
    private $object_spec;
45
46
    public function __construct(string $name, callable $callback, FunctionSpecInterface $spec, $object = null, ?ObjectSpecInterface $object_spec = null)
47
    {
48
        $this->name        = $name;
49
        $this->callback    = $callback;
50
        $this->spec        = $spec;
51
        $this->object      = $object;
52
        $this->object_spec = $object_spec;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getName(): string
59
    {
60
        return $this->name;
61
    }
62
63
    /**
64
     * @return callable
65
     */
66
    public function getCallback(): callable
67
    {
68
        return $this->callback;
69
    }
70
71
    /**
72
     * @return FunctionSpecInterface
73
     */
74
    public function getSpec(): FunctionSpecInterface
75
    {
76
        return $this->spec;
77
    }
78
79
    /**
80
     * @return null|object
81
     */
82
    public function getObject()
83
    {
84
        return $this->object;
85
    }
86
87
    /**
88
     * @return null|ObjectSpecInterface
89
     */
90
    public function getObjectSpec(): ?ObjectSpecInterface
91
    {
92
        return $this->object_spec;
93
    }
94
}
95