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 Psr\Log\NullLogger; |
16
|
|
|
use SimplePie\Configuration as C; |
17
|
|
|
use SimplePie\Mixin as T; |
18
|
|
|
|
19
|
|
|
class Image extends AbstractType implements TypeInterface, C\SetLoggerInterface |
20
|
|
|
{ |
21
|
|
|
use T\LoggerTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The DOMNode element to parse. |
25
|
|
|
* |
26
|
|
|
* @var DOMNode |
27
|
|
|
*/ |
28
|
|
|
protected $node; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* The image element's URL. |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $uri; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The image element's title. |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $title; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The image element's link. |
46
|
|
|
* |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $link; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The image element's width, in pixels. |
53
|
|
|
* |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
protected $width; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The image element's height, in pixels. |
60
|
|
|
* |
61
|
|
|
* @var int |
62
|
|
|
*/ |
63
|
|
|
protected $height; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The image element's description. |
67
|
|
|
* |
68
|
|
|
* @var string |
69
|
|
|
*/ |
70
|
|
|
protected $description; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Constructs a new instance of this class. |
74
|
|
|
* |
75
|
|
|
* @param DOMNode|null $node The `DOMNode` element to parse. |
76
|
|
|
* @param LoggerInterface $logger The PSR-3 logger. |
77
|
|
|
*/ |
78
|
|
|
public function __construct(?DOMNode $node = null, LoggerInterface $logger = null) |
79
|
|
|
{ |
80
|
|
|
if ($node) { |
81
|
|
|
$this->logger = $logger ?? new NullLogger(); |
82
|
|
|
$this->node = $node; |
83
|
|
|
$this->uri = new Node($this->node); |
84
|
|
|
$this->title = null; |
85
|
|
|
$this->link = null; |
86
|
|
|
$this->width = null; |
87
|
|
|
$this->height = null; |
88
|
|
|
$this->description = null; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Converts this object into a string representation. |
94
|
|
|
* |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
public function __toString(): string |
98
|
|
|
{ |
99
|
|
|
return (string) $this->uri ?? ''; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Gets the DOMNode element. |
104
|
|
|
* |
105
|
|
|
* @return DOMNode|null |
106
|
|
|
*/ |
107
|
|
|
public function getNode(): ?DOMNode |
108
|
|
|
{ |
109
|
|
|
return $this->node; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Finds the common internal alias for a given method name. |
114
|
|
|
* |
115
|
|
|
* @param string $nodeName The name of the method being called. |
116
|
|
|
* |
117
|
|
|
* @return string |
118
|
|
|
*/ |
119
|
|
|
protected function getAlias(string $nodeName): string |
120
|
|
|
{ |
121
|
|
|
switch ($nodeName) { |
122
|
|
|
case 'url': |
123
|
|
|
return 'uri'; |
124
|
|
|
|
125
|
|
|
default: |
126
|
|
|
return $nodeName; |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get the correct handler for a whitelisted method name. |
132
|
|
|
* |
133
|
|
|
* @param string $nodeName The name of the method being called. |
134
|
|
|
* |
135
|
|
|
* @throws SimplePieException |
136
|
|
|
* |
137
|
|
|
* @return Node |
138
|
|
|
*/ |
139
|
|
|
protected function getHandler(string $nodeName): Node |
140
|
|
|
{ |
141
|
|
|
switch ($nodeName) { |
142
|
|
|
case 'uri': |
143
|
|
|
case 'title': |
144
|
|
|
case 'link': |
145
|
|
|
case 'width': |
146
|
|
|
case 'height': |
147
|
|
|
case 'description': |
148
|
|
|
return $this->{$nodeName} ?? new Node(); |
149
|
|
|
|
150
|
|
|
default: |
151
|
|
|
throw new SimplePieException( |
|
|
|
|
152
|
|
|
$this->getUnresolvableMessage($nodeName) |
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
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