1 | <?php |
||
2 | |||
3 | /** |
||
4 | * This file is part of slick/di |
||
5 | * |
||
6 | * For the full copyright and license information, please view the LICENSE.md |
||
7 | * file that was distributed with this source code. |
||
8 | */ |
||
9 | |||
10 | namespace Slick\Di\Definition; |
||
11 | |||
12 | use Slick\Di\ContainerAwareMethods; |
||
13 | use Slick\Di\DefinitionInterface; |
||
14 | |||
15 | /** |
||
16 | * Abstract Definition |
||
17 | * |
||
18 | * @package spec\Slick\Di\Definition |
||
19 | * @author Filipe Silva <[email protected]> |
||
20 | */ |
||
21 | abstract class AbstractDefinition implements DefinitionInterface |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @var Scope|string |
||
26 | */ |
||
27 | protected $scope; |
||
28 | |||
29 | /** |
||
30 | * Implements the ContainerAwareInterface |
||
31 | */ |
||
32 | use ContainerAwareMethods; |
||
33 | |||
34 | /** |
||
35 | * Set resolution scope |
||
36 | * |
||
37 | * @param string|Scope $scope |
||
38 | * |
||
39 | * @return self|$this|AbstractDefinition |
||
40 | */ |
||
41 | public function setScope($scope): DefinitionInterface|static |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
42 | { |
||
43 | $this->scope = $scope; |
||
44 | return $this; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Get resolution scope |
||
49 | * |
||
50 | * @return Scope|string |
||
51 | */ |
||
52 | 84 | public function getScope(): string|Scope |
|
53 | { |
||
54 | 84 | if (!$this->scope) { |
|
55 | return Scope::Singleton(); |
||
56 | 84 | } |
|
57 | 84 | return $this->scope; |
|
58 | } |
||
59 | } |
||
60 |