|
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\Decorators\DecoratorSpecInterface; |
|
20
|
|
|
use Pinepain\JsSandbox\Specs\ReturnSpec\ReturnSpecInterface; |
|
21
|
|
|
use Pinepain\JsSandbox\Specs\ThrowSpec\ThrowSpecListInterface; |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
class FunctionSpec implements FunctionSpecInterface |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var ParametersListInterface |
|
28
|
|
|
*/ |
|
29
|
|
|
private $parameters; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var ThrowSpecListInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
private $exceptions; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @var ReturnSpecInterface |
|
37
|
|
|
*/ |
|
38
|
|
|
private $return; |
|
39
|
|
|
/** |
|
40
|
|
|
* @var array|DecoratorSpecInterface[] |
|
41
|
|
|
*/ |
|
42
|
|
|
private $decorators; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param ParametersListInterface $parameters |
|
46
|
|
|
* @param ThrowSpecListInterface $exceptions |
|
47
|
|
|
* @param ReturnSpecInterface $return |
|
48
|
|
|
* @param DecoratorSpecInterface[] $decorators |
|
49
|
|
|
*/ |
|
50
|
13 |
|
public function __construct(ParametersListInterface $parameters, ThrowSpecListInterface $exceptions, ReturnSpecInterface $return, array $decorators = []) |
|
51
|
|
|
{ |
|
52
|
13 |
|
$this->parameters = $parameters; |
|
53
|
13 |
|
$this->exceptions = $exceptions; |
|
54
|
13 |
|
$this->return = $return; |
|
55
|
13 |
|
$this->decorators = $decorators; |
|
56
|
13 |
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
2 |
|
public function getParameters(): ParametersListInterface |
|
62
|
|
|
{ |
|
63
|
2 |
|
return $this->parameters; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritdoc} |
|
68
|
|
|
*/ |
|
69
|
3 |
|
public function getExceptions(): ThrowSpecListInterface |
|
70
|
|
|
{ |
|
71
|
3 |
|
return $this->exceptions; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* {@inheritdoc} |
|
76
|
|
|
*/ |
|
77
|
3 |
|
public function getReturn(): ReturnSpecInterface |
|
78
|
|
|
{ |
|
79
|
3 |
|
return $this->return; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* {@inheritdoc} |
|
84
|
|
|
*/ |
|
85
|
13 |
|
public function getDecorators(): array |
|
86
|
|
|
{ |
|
87
|
13 |
|
return $this->decorators; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
} |
|
91
|
|
|
|