Completed
Pull Request — master (#1203)
by Rafał
10:06
created

ArticleExtraEmbedField   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Content Bundle.
5
 *
6
 * Copyright 2020 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 2020 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
declare(strict_types=1);
16
17
namespace SWP\Bundle\ContentBundle\Model;
18
19
class ArticleExtraEmbedField extends ArticleExtraField implements ArticleExtraEmbedFieldInterface
20
{
21
    protected ?string $embed;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '?', expecting T_FUNCTION or T_CONST
Loading history...
22
23
    protected ?string $description;
24
25
    public static function newFromValue(string $fieldName, array $value): ArticleExtraEmbedFieldInterface
26
    {
27
        $extra = new self();
28
29
        $extra->setFieldName($fieldName);
30
        $extra->setEmbed($value['embed']);
31
        $extra->setDescription($value['description']);
32
33
        return $extra;
34
    }
35
36
    public function setEmbed(?string $embed): void
37
    {
38
        $this->embed = $embed;
39
    }
40
41
    public function getEmbed(): ?string
42
    {
43
        return $this->embed;
44
    }
45
46
    public function setDescription(?string $description): void
47
    {
48
        $this->description = $description;
49
    }
50
51
    public function getDescription(): ?string
52
    {
53
        return $this->description;
54
    }
55
56
    public function toApiFormat(): array
57
    {
58
        return [
59
            'embed' => $this->embed,
60
            'description' => $this->description,
61
        ];
62
    }
63
}
64