1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
namespace TYPO3\PharStreamWrapper\Resolver; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the TYPO3 project. |
7
|
|
|
* |
8
|
|
|
* It is free software; you can redistribute it and/or modify it under the terms |
9
|
|
|
* of the MIT License (MIT). For the full copyright and license information, |
10
|
|
|
* please read the LICENSE file that was distributed with this source code. |
11
|
|
|
* |
12
|
|
|
* The TYPO3 project - inspiring people to share! |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
use TYPO3\PharStreamWrapper\Exception; |
16
|
|
|
|
17
|
|
|
class PharInvocation |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $baseName; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $alias; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var bool |
31
|
|
|
* @see \TYPO3\PharStreamWrapper\PharStreamWrapper::collectInvocation() |
32
|
|
|
*/ |
33
|
|
|
private $confirmed = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Arbitrary variables to be used by interceptors as registry |
37
|
|
|
* (e.g. in order to avoid duplicate processing and assertions) |
38
|
|
|
* |
39
|
|
|
* @var array |
40
|
|
|
*/ |
41
|
|
|
private $variables; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $baseName |
45
|
|
|
* @param string $alias |
46
|
|
|
*/ |
47
|
|
|
public function __construct(string $baseName, string $alias = '') |
48
|
|
|
{ |
49
|
|
|
if ($baseName === '') { |
50
|
|
|
throw new Exception( |
51
|
|
|
'Base-name cannot be empty', |
52
|
|
|
1551283689 |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
$this->baseName = $baseName; |
56
|
|
|
$this->alias = $alias; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
public function __toString(): string |
63
|
|
|
{ |
64
|
|
|
return $this->baseName; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return string |
69
|
|
|
*/ |
70
|
|
|
public function getBaseName(): string |
71
|
|
|
{ |
72
|
|
|
return $this->baseName; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return null|string |
77
|
|
|
*/ |
78
|
|
|
public function getAlias(): string |
79
|
|
|
{ |
80
|
|
|
return $this->alias; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return bool |
85
|
|
|
*/ |
86
|
|
|
public function isConfirmed(): bool |
87
|
|
|
{ |
88
|
|
|
return $this->confirmed; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function confirm() |
92
|
|
|
{ |
93
|
|
|
$this->confirmed = true; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param string $name |
98
|
|
|
* @return mixed|null |
99
|
|
|
*/ |
100
|
|
|
public function getVariable(string $name) |
101
|
|
|
{ |
102
|
|
|
return $this->variables[$name] ?? null; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param string $name |
107
|
|
|
* @param mixed $value |
108
|
|
|
*/ |
109
|
|
|
public function setVariable(string $name, $value) |
110
|
|
|
{ |
111
|
|
|
$this->variables[$name] = $value; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param PharInvocation $other |
116
|
|
|
* @return bool |
117
|
|
|
*/ |
118
|
|
|
public function equals(PharInvocation $other): bool |
119
|
|
|
{ |
120
|
|
|
return $other->baseName === $this->baseName |
121
|
|
|
&& $other->alias === $this->alias; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|