ObjectSpec   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getName() 0 4 1
A getProperties() 0 4 1
A hasProperty() 0 4 1
A getProperty() 0 4 1
A getFunctionSpec() 0 4 1
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\Specs;
17
18
19
class ObjectSpec implements ObjectSpecInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    private $name;
25
    /**
26
     * @var PropertySpecInterface[]|FunctionSpecInterface[]|BindingSpecInterface[]
27
     */
28
    private $properties = [];
29
    /**
30
     * @var null|FunctionSpecInterface
31
     */
32
    private $function_spec;
33
34
    /**
35
     * @param string                                                                 $name
36
     * @param PropertySpecInterface[]|FunctionSpecInterface[]|BindingSpecInterface[] $properties
37
     * @param null|FunctionSpecInterface                                             $function_spec
38
     */
39
    public function __construct(string $name, array $properties, ?FunctionSpecInterface $function_spec = null)
40
    {
41
        $this->name          = $name;
42
        $this->properties    = $properties;
43
        $this->function_spec = $function_spec;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getName(): string
50
    {
51
        return $this->name;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getProperties(): array
58
    {
59
        return $this->properties;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function hasProperty(string $name): bool
66
    {
67
        return isset($this->properties[$name]);
68
    }
69
70
    /**
71
     * {@inheritdoc}
72
     */
73
    public function getProperty(string $name)
74
    {
75
        return $this->properties[$name];
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function getFunctionSpec(): ?FunctionSpecInterface
82
    {
83
        return $this->function_spec;
84
    }
85
}
86