1
|
|
|
<?php namespace FlatPlan; |
2
|
|
|
|
3
|
|
|
use FlatPlan\Components\Ad; |
4
|
|
|
use FlatPlan\Components\Audio; |
5
|
|
|
use FlatPlan\Components\Gallery; |
6
|
|
|
use FlatPlan\Components\Image; |
7
|
|
|
use FlatPlan\Components\Location; |
8
|
|
|
use FlatPlan\Components\Social; |
9
|
|
|
use FlatPlan\Components\Structure; |
10
|
|
|
use FlatPlan\Components\Table; |
|
|
|
|
11
|
|
|
use FlatPlan\Components\Text; |
12
|
|
|
use FlatPlan\Components\Video; |
13
|
|
|
|
14
|
|
|
class Article { |
15
|
|
|
|
16
|
|
|
private $components = array(); |
17
|
|
|
private $defer; |
18
|
|
|
private $articleId; |
19
|
|
|
|
20
|
|
|
public function __construct($articleId, $defer = false) |
21
|
|
|
{ |
22
|
|
|
$this->articleId = $articleId; |
23
|
|
|
$this->defer = $defer; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getJson() |
27
|
|
|
{ |
28
|
|
|
$article = new \stdClass(); |
29
|
|
|
$article->publisher_article_id = $this->articleId; |
30
|
|
|
$article->defer = $this->defer; |
31
|
|
|
$article->components = $this->getComponents(); |
32
|
|
|
|
33
|
|
|
return json_encode($article); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function getComponents($format = null) |
37
|
|
|
{ |
38
|
|
|
return $format === 'json' ? json_encode($this->components) : $this->components; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @param Text $component |
43
|
|
|
* @throws \ErrorException |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function addTextComponent($component) |
47
|
|
|
{ |
48
|
|
|
if ($component instanceof Text) { |
|
|
|
|
49
|
|
|
array_push($this->components, $component); |
50
|
|
|
} else { |
51
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param Image $component |
57
|
|
|
* @throws \ErrorException |
58
|
|
|
* @return void |
59
|
|
|
*/ |
60
|
|
|
public function addImageComponent($component) |
61
|
|
|
{ |
62
|
|
|
if ($component instanceof Image) { |
|
|
|
|
63
|
|
|
array_push($this->components, $component); |
64
|
|
|
} else { |
65
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param Gallery $component |
71
|
|
|
* @throws \ErrorException |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
public function addGalleryComponent($component) |
75
|
|
|
{ |
76
|
|
|
if ($component instanceof Gallery) { |
|
|
|
|
77
|
|
|
array_push($this->components, $component); |
78
|
|
|
} else { |
79
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param Audio $component |
85
|
|
|
* @throws \ErrorException |
86
|
|
|
* @return void |
87
|
|
|
*/ |
88
|
|
|
public function addAudioComponent($component) |
89
|
|
|
{ |
90
|
|
|
if ($component instanceof Audio) { |
|
|
|
|
91
|
|
|
array_push($this->components, $component); |
92
|
|
|
} else { |
93
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @param Video $component |
99
|
|
|
* @throws \ErrorException |
100
|
|
|
* @return void |
101
|
|
|
*/ |
102
|
|
|
public function addVideoComponent($component) |
103
|
|
|
{ |
104
|
|
|
if ($component instanceof Video) { |
|
|
|
|
105
|
|
|
array_push($this->components, $component); |
106
|
|
|
} else { |
107
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param Map $component |
113
|
|
|
* @throws \ErrorException |
114
|
|
|
* @return void |
115
|
|
|
*/ |
116
|
|
|
public function addMapComponent($component) |
117
|
|
|
{ |
118
|
|
|
if ($component instanceof Map) { |
|
|
|
|
119
|
|
|
array_push($this->components, $component); |
120
|
|
|
} else { |
121
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @param Social $component |
127
|
|
|
* @throws \ErrorException |
128
|
|
|
* @return void |
129
|
|
|
*/ |
130
|
|
|
public function addSocialComponent($component) |
131
|
|
|
{ |
132
|
|
|
if ($component instanceof Social) { |
|
|
|
|
133
|
|
|
array_push($this->components, $component); |
134
|
|
|
} else { |
135
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
136
|
|
|
} |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param Ad $component |
141
|
|
|
* @throws \ErrorException |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function addAdComponent($component) |
145
|
|
|
{ |
146
|
|
|
if ($component instanceof Ad) { |
|
|
|
|
147
|
|
|
array_push($this->components, $component); |
148
|
|
|
} else { |
149
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @param Structure $component |
155
|
|
|
* @throws \ErrorException |
156
|
|
|
* @return void |
157
|
|
|
*/ |
158
|
|
|
public function addStructureComponent($component) |
159
|
|
|
{ |
160
|
|
|
if ($component instanceof Structure) { |
|
|
|
|
161
|
|
|
array_push($this->components, $component); |
162
|
|
|
} else { |
163
|
|
|
throw new \ErrorException('Invalid component supplied.'); |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
} |
167
|
|
|
|
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