Scraper::getSources()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace TreeHouse\IoBundle\Entity;
4
5
use Doctrine\Common\Collections\ArrayCollection;
6
use Doctrine\ORM\Mapping as ORM;
7
use TreeHouse\IoBundle\Model\OriginInterface;
8
use TreeHouse\IoBundle\Model\SourceInterface;
9
10
/**
11
 * @ORM\Entity(repositoryClass="ScraperRepository")
12
 * @ORM\Table
13
 */
14
class Scraper
15
{
16
    /**
17
     * @var int
18
     *
19
     * @ORM\Column(type="integer")
20
     * @ORM\Id
21
     * @ORM\GeneratedValue(strategy="AUTO")
22
     */
23
    protected $id;
24
25
    /**
26
     * The frequency to start the scraper, in hours.
27
     *
28
     * @var int
29
     *
30
     * @ORM\Column(type="integer")
31
     */
32
    protected $startFrequency;
33
34
    /**
35
     * The frequency to revisit sources, in hours.
36
     *
37
     * @var int
38
     *
39
     * @ORM\Column(type="integer")
40
     */
41
    protected $revisitFrequency;
42
43
    /**
44
     * One of the configured crawler types.
45
     *
46
     * @var string
47
     *
48
     * @ORM\Column(type="string")
49
     */
50
    protected $crawler;
51
52
    /**
53
     * Options to be passed to the crawler type.
54
     *
55
     * @var array
56
     *
57
     * @ORM\Column(type="json_array", nullable=true)
58
     */
59
    protected $crawlerOptions;
60
61
    /**
62
     * One of the configured parser types.
63
     *
64
     * @var string
65
     *
66
     * @ORM\Column(type="string")
67
     */
68
    protected $parser;
69
70
    /**
71
     * Options to be passed to the parser type.
72
     *
73
     * @var array
74
     *
75
     * @ORM\Column(type="json_array", nullable=true)
76
     */
77
    protected $parserOptions;
78
79
    /**
80
     * One of the configured handlers.
81
     *
82
     * @var string
83
     *
84
     * @ORM\Column(type="string")
85
     */
86
    protected $handler;
87
88
    /**
89
     * The root url.
90
     *
91
     * @var string
92
     *
93
     * @ORM\Column(type="string")
94
     */
95
    protected $url;
96
97
    /**
98
     * Can contain key/value pairs to be used as defaults if the scraped pages doesn't supply them.
99
     *
100
     * @var array
101
     *
102
     * @ORM\Column(type="json_array", nullable=true)
103
     */
104
    protected $defaultValues;
105
106
    /**
107
     * @var \DateTime
108
     *
109
     * @ORM\Column(type="datetime", nullable=true)
110
     */
111
    protected $datetimeLastStarted;
112
113
    /**
114
     * @var OriginInterface
115
     *
116
     * @ORM\ManyToOne(targetEntity="TreeHouse\IoBundle\Model\OriginInterface", inversedBy="scrapers", cascade={"persist"})
117
     */
118
    protected $origin;
119
120
    /**
121
     * @var SourceInterface
122
     *
123
     * @ORM\OneToMany(targetEntity="TreeHouse\IoBundle\Model\SourceInterface", mappedBy="scraper", cascade={"persist", "remove"})
124
     */
125
    protected $sources;
126
127
    /**
128
     * Constructor.
129
     */
130 40
    public function __construct()
131
    {
132 40
        $this->sources = new ArrayCollection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Doctrine\Common\Collections\ArrayCollection() of type object<Doctrine\Common\C...ctions\ArrayCollection> is incompatible with the declared type object<TreeHouse\IoBundle\Model\SourceInterface> of property $sources.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
133 40
    }
134
135
    /**
136
     * @return string
137
     */
138
    public function __toString()
139
    {
140
        return $this->url;
141
    }
142
143
    /**
144
     * @return int
145
     */
146
    public function getId()
147
    {
148
        return $this->id;
149
    }
150
151
    /**
152
     * @param int $startFrequency
153
     *
154
     * @return $this
155
     */
156
    public function setStartFrequency($startFrequency)
157
    {
158
        $this->startFrequency = $startFrequency;
159
160
        return $this;
161
    }
162
163
    /**
164
     * @return int
165
     */
166
    public function getStartFrequency()
167
    {
168
        return $this->startFrequency;
169
    }
170
171
    /**
172
     * @param int $revisitFrequency
173
     *
174
     * @return $this
175
     */
176
    public function setRevisitFrequency($revisitFrequency)
177
    {
178
        $this->revisitFrequency = $revisitFrequency;
179
180
        return $this;
181
    }
182
183
    /**
184
     * @return int
185
     */
186
    public function getRevisitFrequency()
187
    {
188
        return $this->revisitFrequency;
189
    }
190
191
    /**
192
     * @param string $crawler
193
     *
194
     * @return $this
195
     */
196
    public function setCrawler($crawler)
197
    {
198
        $this->crawler = $crawler;
199
200
        return $this;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    public function getCrawler()
207
    {
208
        return $this->crawler;
209
    }
210
211
    /**
212
     * @param array $crawlerOptions
213
     *
214
     * @return $this
215
     */
216
    public function setCrawlerOptions(array $crawlerOptions)
217
    {
218
        $this->crawlerOptions = $crawlerOptions;
219
220
        return $this;
221
    }
222
223
    /**
224
     * @return array
225
     */
226
    public function getCrawlerOptions()
227
    {
228
        return $this->crawlerOptions;
229
    }
230
231
    /**
232
     * @param string $parser
233
     *
234
     * @return $this
235
     */
236
    public function setParser($parser)
237
    {
238
        $this->parser = $parser;
239
240
        return $this;
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    public function getParser()
247
    {
248
        return $this->parser;
249
    }
250
251
    /**
252
     * @param array $parserOptions
253
     *
254
     * @return $this
255
     */
256
    public function setParserOptions(array $parserOptions)
257
    {
258
        $this->parserOptions = $parserOptions;
259
260
        return $this;
261
    }
262
263
    /**
264
     * @return array
265
     */
266
    public function getParserOptions()
267
    {
268
        return $this->parserOptions;
269
    }
270
271
    /**
272
     * @param string $handler
273
     *
274
     * @return $this
275
     */
276
    public function setHandler($handler)
277
    {
278
        $this->handler = $handler;
279
280
        return $this;
281
    }
282
283
    /**
284
     * @return string
285
     */
286
    public function getHandler()
287
    {
288
        return $this->handler;
289
    }
290
291
    /**
292
     * @param string $url
293
     *
294
     * @return $this
295
     */
296
    public function setUrl($url)
297
    {
298
        $this->url = $url;
299
300
        return $this;
301
    }
302
303
    /**
304
     * @return string
305
     */
306
    public function getUrl()
307
    {
308
        return $this->url;
309
    }
310
311
    /**
312
     * @param array $defaultValues
313
     *
314
     * @return $this
315
     */
316
    public function setDefaultValues(array $defaultValues)
317
    {
318
        $this->defaultValues = $defaultValues;
319
320
        return $this;
321
    }
322
323
    /**
324
     * @return array
325
     */
326
    public function getDefaultValues()
327
    {
328
        return $this->defaultValues;
329
    }
330
331
    /**
332
     * @param \DateTime $datetimeLastStarted
333
     *
334
     * @return $this
335
     */
336
    public function setDatetimeLastStarted(\DateTime $datetimeLastStarted = null)
337
    {
338
        $this->datetimeLastStarted = $datetimeLastStarted;
339
340
        return $this;
341
    }
342
343
    /**
344
     * @return \DateTime
345
     */
346
    public function getDatetimeLastStarted()
347
    {
348
        return $this->datetimeLastStarted;
349
    }
350
351
    /**
352
     * @param OriginInterface $origin
353
     *
354
     * @return $this
355
     */
356
    public function setOrigin(OriginInterface $origin = null)
357
    {
358
        $this->origin = $origin;
359
360
        return $this;
361
    }
362
363
    /**
364
     * @return OriginInterface
365
     */
366
    public function getOrigin()
367
    {
368
        return $this->origin;
369
    }
370
371
    /**
372
     * @param SourceInterface $source
373
     *
374
     * @return $this
375
     */
376
    public function addSource(SourceInterface $source)
377
    {
378
        $this->sources[] = $source;
379
380
        return $this;
381
    }
382
383
    /**
384
     * @param SourceInterface $source
385
     */
386
    public function removeSource(SourceInterface $source)
387
    {
388
        $this->sources->removeElement($source);
0 ignored issues
show
Bug introduced by
The method removeElement() does not seem to exist on object<TreeHouse\IoBundle\Model\SourceInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
389
    }
390
391
    /**
392
     * @return SourceInterface[]|ArrayCollection
393
     */
394
    public function getSources()
395
    {
396
        return $this->sources;
397
    }
398
}
399