Completed
Push — 1.5 ( dc62f6...bc7363 )
by Rafał
10:57
created

BaseContent::getCopyrightNotice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Bridge Component.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Component\Bridge\Model;
16
17
use Doctrine\Common\Collections\ArrayCollection;
18
19
class BaseContent implements ContentInterface
20
{
21
    use AuthorsAwareTrait;
22
23
    /**
24
     * @var mixed
25
     */
26
    protected $id;
27
28
    /**
29
     * @var string
30
     */
31
    protected $guid;
32
33
    /**
34
     * @var string
35
     */
36
    protected $headline;
37
38
    /**
39
     * @var string
40
     */
41
    protected $byline;
42
43
    /**
44
     * @var string
45
     */
46
    protected $slugline;
47
48
    /**
49
     * @var string
50
     */
51
    protected $language;
52
53
    /**
54
     * @var array
55
     */
56
    protected $subjects = [];
57
58
    /**
59
     * @var string
60
     */
61
    protected $type;
62
63
    /**
64
     * @var array
65
     */
66
    protected $places = [];
67
68
    /**
69
     * @var array
70
     */
71
    protected $services = [];
72
73
    /**
74
     * @var string
75
     */
76
    protected $located;
77
78
    /**
79
     * @var int
80
     */
81
    protected $urgency = 0;
82
83
    /**
84
     * @var int
85
     */
86
    protected $priority;
87
88
    /**
89
     * @var int
90
     */
91
    protected $version;
92
93
    /**
94
     * @var string
95
     */
96
    protected $genre;
97
98
    /**
99
     * @var string
100
     */
101
    protected $edNote;
102
103
    /**
104
     * @var string
105
     */
106
    protected $description;
107
108
    /**
109
     * @var array
110
     */
111
    protected $keywords = [];
112
113
    /**
114
     * @var string
115
     */
116
    protected $pubStatus = ContentInterface::STATUS_USABLE;
117
118
    /**
119
     * @var string|null
120
     */
121
    protected $evolvedFrom;
122
123
    /**
124
     * @var string|null
125
     */
126
    protected $source;
127
128
    /**
129
     * @var array
130
     */
131
    protected $extra = [];
132
133
    /**
134
     * @var \DateTimeInterface|null
135
     */
136
    protected $firstPublishedAt;
137
138
    /**
139
     * @var string|null
140
     */
141
    protected $copyrightNotice;
142
143
    /**
144
     * @var string|null
145
     */
146
    protected $copyrightHolder;
147
148
    public function __construct()
149
    {
150
        $this->authors = new ArrayCollection();
151
    }
152
153
    /**
154
     * @return mixed
155
     */
156
    public function getId()
157
    {
158
        return $this->id;
159
    }
160
161
    /**
162
     * {@inheritdoc}
163
     */
164
    public function setId($id)
165
    {
166
        $this->id = $id;
167
    }
168
169
    /**
170
     * {@inheritdoc}
171
     */
172
    public function getByline()
173
    {
174
        return $this->byline;
175
    }
176
177
    /**
178
     * {@inheritdoc}
179
     */
180
    public function setByline($byline)
181
    {
182
        $this->byline = $byline;
183
    }
184
185
    /**
186
     * {@inheritdoc}
187
     */
188
    public function getSlugline()
189
    {
190
        return $this->slugline;
191
    }
192
193
    /**
194
     * {@inheritdoc}
195
     */
196
    public function setSlugline($slugline)
197
    {
198
        $this->slugline = $slugline;
199
    }
200
201
    /**
202
     * {@inheritdoc}
203
     */
204
    public function getLanguage()
205
    {
206
        return $this->language;
207
    }
208
209
    /**
210
     * {@inheritdoc}
211
     */
212
    public function setLanguage($language)
213
    {
214
        $this->language = $language;
215
    }
216
217
    /**
218
     * {@inheritdoc}
219
     */
220
    public function getSubjects()
221
    {
222
        return $this->subjects;
223
    }
224
225
    /**
226
     * {@inheritdoc}
227
     */
228
    public function setSubjects(array $subjects = [])
229
    {
230
        $this->subjects = $subjects;
231
    }
232
233
    /**
234
     * {@inheritdoc}
235
     */
236
    public function getType()
237
    {
238
        return $this->type;
239
    }
240
241
    /**
242
     * {@inheritdoc}
243
     */
244
    public function setType($type)
245
    {
246
        $this->type = $type;
247
    }
248
249
    /**
250
     * {@inheritdoc}
251
     */
252
    public function getPlaces()
253
    {
254
        return $this->places;
255
    }
256
257
    /**
258
     * {@inheritdoc}
259
     */
260
    public function setPlaces($places)
261
    {
262
        $this->places = $places;
263
    }
264
265
    /**
266
     * {@inheritdoc}
267
     */
268
    public function getLocated()
269
    {
270
        return $this->located;
271
    }
272
273
    /**
274
     * {@inheritdoc}
275
     */
276
    public function setLocated($located)
277
    {
278
        $this->located = $located;
279
    }
280
281
    /**
282
     * {@inheritdoc}
283
     */
284
    public function getUrgency()
285
    {
286
        return $this->urgency;
287
    }
288
289
    /**
290
     * {@inheritdoc}
291
     */
292
    public function setUrgency($urgency)
293
    {
294
        $this->urgency = $urgency;
295
    }
296
297
    /**
298
     * {@inheritdoc}
299
     */
300
    public function getPriority()
301
    {
302
        return $this->priority;
303
    }
304
305
    /**
306
     * {@inheritdoc}
307
     */
308
    public function setPriority($priority)
309
    {
310
        $this->priority = $priority;
311
    }
312
313
    /**
314
     * {@inheritdoc}
315
     */
316
    public function getVersion()
317
    {
318
        return $this->version;
319
    }
320
321
    /**
322
     * {@inheritdoc}
323
     */
324
    public function setVersion($version)
325
    {
326
        $this->version = $version;
327
    }
328
329
    /**
330
     * {@inheritdoc}
331
     */
332
    public function getHeadline()
333
    {
334
        return $this->headline;
335
    }
336
337
    /**
338
     * {@inheritdoc}
339
     */
340
    public function setHeadline($headline)
341
    {
342
        $this->headline = $headline;
343
    }
344
345
    /**
346
     * {@inheritdoc}
347
     */
348
    public function getGuid()
349
    {
350
        return $this->guid;
351
    }
352
353
    /**
354
     * {@inheritdoc}
355
     */
356
    public function setGuid($guid)
357
    {
358
        $this->guid = $guid;
359
    }
360
361
    /**
362
     * {@inheritdoc}
363
     */
364
    public function getServices()
365
    {
366
        return $this->services;
367
    }
368
369
    /**
370
     * {@inheritdoc}
371
     */
372
    public function getServicesNames(): array
373
    {
374
        return $this->mapNames($this->services);
375
    }
376
377
    /**
378
     * {@inheritdoc}
379
     */
380
    public function getServicesCodes(): array
381
    {
382
        return $this->mapCodes($this->services);
383
    }
384
385
    public function getSubjectsSchemes(): array
386
    {
387
        return $this->mapSchemes($this->subjects);
388
    }
389
390
    public function getSubjectsNames(): array
391
    {
392
        return $this->mapNames($this->subjects);
393
    }
394
395
    private function mapNames(array $values): array
396
    {
397
        return array_map(function ($subject) {
398
            if (\is_array($subject) && \array_key_exists('name', $subject)) {
399
                return $subject['name'];
400
            }
401
402
            return $subject;
403
        }, $values);
404
    }
405
406
    private function mapCodes(array $values): array
407
    {
408
        return array_map(function ($subject) {
409
            if (\is_array($subject) && \array_key_exists('code', $subject)) {
410
                return $subject['code'];
411
            }
412
413
            return $subject;
414
        }, $values);
415
    }
416
417
    private function mapSchemes(array $values): array
418
    {
419
        return array_map(function ($subject) {
420
            if (\is_array($subject) && \array_key_exists('scheme', $subject)) {
421
                return $subject['scheme'];
422
            }
423
424
            return $subject;
425
        }, $values);
426
    }
427
428
    /**
429
     * {@inheritdoc}
430
     */
431
    public function setServices(array $services = [])
432
    {
433
        $this->services = $services;
434
    }
435
436
    /**
437
     * {@inheritdoc}
438
     */
439
    public function getEdNote()
440
    {
441
        return $this->edNote;
442
    }
443
444
    /**
445
     * {@inheritdoc}
446
     */
447
    public function setEdNote($edNote)
448
    {
449
        $this->edNote = $edNote;
450
    }
451
452
    /**
453
     * {@inheritdoc}
454
     */
455
    public function getGenre()
456
    {
457
        return $this->genre;
458
    }
459
460
    /**
461
     * {@inheritdoc}
462
     */
463
    public function setGenre($genre)
464
    {
465
        $this->genre = $genre;
466
    }
467
468
    /**
469
     * @return string
470
     */
471
    public function getDescription()
472
    {
473
        return $this->description;
474
    }
475
476
    /**
477
     * @param string $description
478
     */
479
    public function setDescription($description)
480
    {
481
        $this->description = $description;
482
    }
483
484
    /**
485
     * {@inheritdoc}
486
     */
487
    public function getMetadata()
488
    {
489
        return [
490
            'subject' => $this->getSubjects(),
491
            'urgency' => $this->getUrgency(),
492
            'priority' => $this->getPriority(),
493
            'located' => $this->getLocated(),
494
            'place' => $this->getPlaces(),
495
            'service' => $this->getServices(),
496
            'type' => $this->getType(),
497
            'byline' => $this->getByline(),
498
            'guid' => $this->getGuid(),
499
            'edNote' => $this->getEdNote(),
500
            'genre' => $this->getGenre(),
501
            'language' => $this->getLanguage(),
502
        ];
503
    }
504
505
    /**
506
     * {@inheritdoc}
507
     */
508
    public function getKeywords()
509
    {
510
        return $this->keywords;
511
    }
512
513
    /**
514
     * {@inheritdoc}
515
     */
516
    public function setKeywords(array $keywords)
517
    {
518
        $this->keywords = $keywords;
519
    }
520
521
    /**
522
     * {@inheritdoc}
523
     */
524
    public function getPubStatus()
525
    {
526
        return $this->pubStatus;
527
    }
528
529
    /**
530
     * {@inheritdoc}
531
     */
532
    public function setPubStatus(string $pubStatus)
533
    {
534
        $this->pubStatus = $pubStatus;
535
    }
536
537
    /**
538
     * {@inheritdoc}
539
     */
540
    public function getEvolvedFrom()
541
    {
542
        return $this->evolvedFrom;
543
    }
544
545
    /**
546
     * {@inheritdoc}
547
     */
548
    public function setEvolvedFrom(string $evolvedFrom)
549
    {
550
        $this->evolvedFrom = $evolvedFrom;
551
    }
552
553
    /**
554
     * {@inheritdoc}
555
     */
556
    public function getSource()
557
    {
558
        return $this->source;
559
    }
560
561
    /**
562
     * {@inheritdoc}
563
     */
564
    public function setSource($source)
565
    {
566
        $this->source = $source;
567
    }
568
569
    /**
570
     * {@inheritdoc}
571
     */
572
    public function getExtra(): array
573
    {
574
        if (null === $this->extra) {
575
            return [];
576
        }
577
578
        return $this->extra;
579
    }
580
581
    /**
582
     * {@inheritdoc}
583
     */
584
    public function setExtra(?array $extra): void
585
    {
586
        $this->extra = $extra;
0 ignored issues
show
Documentation Bug introduced by
It seems like $extra can be null. However, the property $extra is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

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

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
587
    }
588
589
    public function getFirstPublishedAt(): ?\DateTimeInterface
590
    {
591
        return $this->firstPublishedAt;
592
    }
593
594
    public function setFirstPublishedAt(?\DateTimeInterface $firstPublishedAt): void
595
    {
596
        $this->firstPublishedAt = $firstPublishedAt;
597
    }
598
599
    public function getCopyrightNotice(): ?string
600
    {
601
        return $this->copyrightNotice;
602
    }
603
604
    public function setCopyrightNotice(?string $copyrightNotice): void
605
    {
606
        $this->copyrightNotice = $copyrightNotice;
607
    }
608
609
    public function getCopyrightHolder(): ?string
610
    {
611
        return $this->copyrightHolder;
612
    }
613
614
    public function setCopyrightHolder(?string $copyrightHolder): void
615
    {
616
        $this->copyrightHolder = $copyrightHolder;
617
    }
618
}
619