|
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
|
|
|
use Pinepain\JsSandbox\Extractors\Definition\ExtractorDefinitionInterface; |
|
20
|
|
|
|
|
21
|
|
|
|
|
22
|
|
|
class PropertySpec implements PropertySpecInterface |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var bool |
|
26
|
|
|
*/ |
|
27
|
|
|
private $is_readonly; |
|
28
|
|
|
/** |
|
29
|
|
|
* @var null|ExtractorDefinitionInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
private $extractor_definition; |
|
32
|
|
|
/** |
|
33
|
|
|
* @var null|string |
|
34
|
|
|
*/ |
|
35
|
|
|
private $getter; |
|
36
|
|
|
/** |
|
37
|
|
|
* @var null|string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $setter; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param bool $is_readonly |
|
43
|
|
|
* @param null|ExtractorDefinitionInterface $extractor_definition |
|
44
|
|
|
* @param null|string $getter |
|
45
|
|
|
* @param null|string $setter |
|
46
|
|
|
*/ |
|
47
|
4 |
|
public function __construct(bool $is_readonly, ?ExtractorDefinitionInterface $extractor_definition, ?string $getter = null, ?string $setter = null) |
|
48
|
|
|
{ |
|
49
|
4 |
|
$this->is_readonly = $is_readonly; |
|
50
|
4 |
|
$this->extractor_definition = $extractor_definition; |
|
51
|
4 |
|
$this->getter = $getter; |
|
52
|
4 |
|
$this->setter = $setter; // NOTE: having both $is_readonly and $setter set doesn't make much sense |
|
53
|
4 |
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* {@inheritdoc} |
|
57
|
|
|
*/ |
|
58
|
4 |
|
public function isReadonly(): bool |
|
59
|
|
|
{ |
|
60
|
4 |
|
return $this->is_readonly; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
4 |
|
public function getExtractorDefinition(): ?ExtractorDefinitionInterface |
|
67
|
|
|
{ |
|
68
|
4 |
|
return $this->extractor_definition; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* {@inheritdoc} |
|
73
|
|
|
*/ |
|
74
|
4 |
|
public function getGetterName(): ?string |
|
75
|
|
|
{ |
|
76
|
4 |
|
return $this->getter; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* {@inheritdoc} |
|
81
|
|
|
*/ |
|
82
|
4 |
|
public function getSetterName(): ?string |
|
83
|
|
|
{ |
|
84
|
4 |
|
return $this->setter; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
|