1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2017 Ryan Parman <http://ryanparman.com>. |
4
|
|
|
* Copyright (c) 2017 Contributors. |
5
|
|
|
* |
6
|
|
|
* http://opensource.org/licenses/Apache2.0 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace SimplePie\Type; |
12
|
|
|
|
13
|
|
|
use DOMNode; |
14
|
|
|
use Psr\Log\LoggerInterface; |
15
|
|
|
use SimplePie\Configuration as C; |
16
|
|
|
use SimplePie\Mixin as T; |
17
|
|
|
|
18
|
|
|
class Person extends AbstractType implements TypeInterface, C\SetLoggerInterface |
19
|
|
|
{ |
20
|
|
|
use T\LoggerTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* The DOMNode element to parse. |
24
|
|
|
* |
25
|
|
|
* @var DOMNode |
26
|
|
|
*/ |
27
|
|
|
protected $node; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* The person's name. |
31
|
|
|
* |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $name; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* The person's URL. |
38
|
|
|
* |
39
|
|
|
* @var string |
40
|
|
|
*/ |
41
|
|
|
protected $uri; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The person's email address. |
45
|
|
|
* |
46
|
|
|
* @var string |
47
|
|
|
*/ |
48
|
|
|
protected $email; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The person's avatar. |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $avatar; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Constructs a new instance of this class. |
59
|
|
|
* |
60
|
|
|
* @param DOMNode|null $node The `DOMNode` element to parse. |
61
|
|
|
* @param LoggerInterface $logger The PSR-3 logger. |
62
|
|
|
*/ |
63
|
|
|
public function __construct(?DOMNode $node = null, LoggerInterface $logger = null) |
64
|
|
|
{ |
65
|
|
|
if ($node) { |
66
|
|
|
$this->logger = $logger ?? new NullLogger(); |
|
|
|
|
67
|
|
|
$this->node = $node; |
68
|
|
|
$this->name = new Node($this->node); |
69
|
|
|
|
70
|
|
|
foreach ($this->node->childNodes as $child) { |
71
|
|
|
$this->{$child->tagName} = new Node($child); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Converts this object into a string representation. |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function __toString(): string |
82
|
|
|
{ |
83
|
|
|
if (null !== $this->name && (null !== $this->uri || null !== $this->email) |
84
|
|
|
) { |
85
|
|
|
return \trim(\sprintf('%s <%s>', (string) $this->name, (string) $this->uri ?? (string) $this->email)); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return \trim( |
89
|
|
|
(string) $this->name |
90
|
|
|
?? (string) $this->uri |
91
|
|
|
?? (string) $this->email |
92
|
|
|
?? 'Unknown' |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Gets the DOMNode element. |
98
|
|
|
* |
99
|
|
|
* @return DOMNode|null |
100
|
|
|
*/ |
101
|
|
|
public function getNode(): ?DOMNode |
102
|
|
|
{ |
103
|
|
|
return $this->node; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Finds the common internal alias for a given method name. |
108
|
|
|
* |
109
|
|
|
* @param string $nodeName The name of the method being called. |
110
|
|
|
* |
111
|
|
|
* @return string |
112
|
|
|
*/ |
113
|
|
|
protected function getAlias(string $nodeName): string |
114
|
|
|
{ |
115
|
|
|
switch ($nodeName) { |
116
|
|
|
case 'url': |
117
|
|
|
return 'uri'; |
118
|
|
|
|
119
|
|
|
default: |
120
|
|
|
return $nodeName; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Get the correct handler for a whitelisted method name. |
126
|
|
|
* |
127
|
|
|
* @param string $nodeName The name of the method being called. |
128
|
|
|
* |
129
|
|
|
* @throws SimplePieException |
130
|
|
|
* |
131
|
|
|
* @return Node |
132
|
|
|
*/ |
133
|
|
|
protected function getHandler(string $nodeName): Node |
134
|
|
|
{ |
135
|
|
|
switch ($nodeName) { |
136
|
|
|
case 'name': |
137
|
|
|
case 'uri': |
138
|
|
|
case 'email': |
139
|
|
|
case 'avatar': |
140
|
|
|
return $this->{$nodeName} ?? new Node(); |
141
|
|
|
|
142
|
|
|
default: |
143
|
|
|
throw new SimplePieException( |
|
|
|
|
144
|
|
|
\sprintf('%s is an unresolvable method.') |
145
|
|
|
); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
} |
149
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths