1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2017–2019 Ryan Parman <http://ryanparman.com>. |
4
|
|
|
* Copyright (c) 2017–2019 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\Exception\SimplePieException; |
18
|
|
|
use SimplePie\Mixin as Tr; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* A type model for an Image element. |
22
|
|
|
* |
23
|
|
|
* @method SimplePie\Type\Node getDescription() Returns the description of the Image. |
24
|
|
|
* @method SimplePie\Type\Node getHeight() Returns the height of the Image. |
25
|
|
|
* @method SimplePie\Type\Node getLink() Returns to where the Image should be linked. |
26
|
|
|
* @method SimplePie\Type\Node getTitle() Returns the title of the Image. |
27
|
|
|
* @method SimplePie\Type\Node getUri() Alias for `getUrl()`. |
28
|
|
|
* @method SimplePie\Type\Node getUrl() Returns the URL of the Image. |
29
|
|
|
* @method SimplePie\Type\Node getWidth() Returns the width of the Image. |
30
|
|
|
* |
31
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-Atom-1.0#425-the-atomicon-element |
32
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-Atom-1.0#428-the-atomlogo-element |
33
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-RSS-1.0#534-image |
34
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-RSS-2.0#image-sub-element-of-channel |
35
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-JSON-Feed-v1#top-level |
36
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-iTunes-Podcast-RSS#itunesimage |
37
|
|
|
* @see https://github.com/simplepie/simplepie-ng/wiki/Spec%3A-Media-RSS#mediathumbnails |
38
|
|
|
*/ |
39
|
|
|
class Image extends AbstractType implements C\SetLoggerInterface, NodeInterface, TypeInterface |
40
|
|
|
{ |
41
|
|
|
use Tr\LoggerTrait; |
|
|
|
|
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* The DOMNode element to parse. |
45
|
|
|
* |
46
|
|
|
* @var DOMNode |
47
|
|
|
*/ |
48
|
|
|
protected $node; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* The image element's URL. |
52
|
|
|
* |
53
|
|
|
* @var string |
54
|
|
|
*/ |
55
|
|
|
protected $uri; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* The image element's title. |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
protected $title; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* The image element's link. |
66
|
|
|
* |
67
|
|
|
* @var string |
68
|
|
|
*/ |
69
|
|
|
protected $link; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* The image element's width, in pixels. |
73
|
|
|
* |
74
|
|
|
* @var int |
75
|
|
|
*/ |
76
|
|
|
protected $width; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* The image element's height, in pixels. |
80
|
|
|
* |
81
|
|
|
* @var int |
82
|
|
|
*/ |
83
|
|
|
protected $height; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* The image element's description. |
87
|
|
|
* |
88
|
|
|
* @var string |
89
|
|
|
*/ |
90
|
|
|
protected $description; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Constructs a new instance of this class. |
94
|
|
|
* |
95
|
|
|
* @param DOMNode|null $node The `DOMNode` element to parse. |
96
|
|
|
* @param LoggerInterface $logger The PSR-3 logger. |
97
|
|
|
*/ |
98
|
6 |
|
public function __construct(?DOMNode $node = null, LoggerInterface $logger = null) |
99
|
|
|
{ |
100
|
6 |
|
if ($node) { |
101
|
6 |
|
$this->logger = $logger ?? new NullLogger(); |
|
|
|
|
102
|
6 |
|
$this->node = $node; |
103
|
6 |
|
$this->uri = new Node($this->node); |
104
|
6 |
|
$this->title = null; |
105
|
6 |
|
$this->link = null; |
106
|
6 |
|
$this->width = null; |
107
|
6 |
|
$this->height = null; |
108
|
6 |
|
$this->description = null; |
109
|
|
|
} |
110
|
6 |
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* {@inheritdoc} |
114
|
|
|
*/ |
115
|
4 |
|
public function __toString(): string |
116
|
|
|
{ |
117
|
4 |
|
return (string) $this->uri ?? ''; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* {@inheritdoc} |
122
|
|
|
*/ |
123
|
2 |
|
public function getNode(): ?DOMNode |
124
|
|
|
{ |
125
|
2 |
|
return $this->node; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* {@inheritdoc} |
130
|
|
|
*/ |
131
|
4 |
|
public function getAlias(string $nodeName): string |
132
|
|
|
{ |
133
|
4 |
|
switch ($nodeName) { |
134
|
4 |
|
case 'url': |
135
|
3 |
|
return 'uri'; |
136
|
|
|
|
137
|
|
|
default: |
138
|
2 |
|
return $nodeName; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* {@inheritdoc} |
144
|
|
|
*/ |
145
|
4 |
|
public function getHandler(string $nodeName, array $args = []): Node |
146
|
|
|
{ |
147
|
|
|
// Shut up, linter. |
148
|
|
|
$args; |
149
|
|
|
|
150
|
4 |
|
switch ($nodeName) { |
151
|
4 |
|
case 'uri': |
152
|
1 |
|
case 'title': |
153
|
1 |
|
case 'link': |
154
|
1 |
|
case 'width': |
155
|
1 |
|
case 'height': |
156
|
1 |
|
case 'description': |
157
|
3 |
|
return $this->{$nodeName} ?? new Node(); |
158
|
|
|
|
159
|
|
|
default: |
160
|
1 |
|
throw new SimplePieException( |
161
|
1 |
|
$this->getUnresolvableMessage($nodeName) |
162
|
|
|
); |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|
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