Passed
Push — master ( dbe2f7...33ec41 )
by Joppe
09:56 queued 06:03
created

ProductSeo::setTwitterCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace JoppeDc\SyliusBetterSeoPlugin\Entity;
6
7
use Sylius\Component\Core\Model\ProductTranslationInterface;
8
use Sylius\Component\Product\Model\ProductInterface;
9
use Sylius\Component\Resource\Model\ResourceInterface;
10
use Sylius\Component\Resource\Model\TranslatableInterface;
11
use Sylius\Component\Resource\Model\TranslatableTrait;
12
use Sylius\Component\Resource\Model\TranslationInterface;
13
14
class ProductSeo implements TranslatableInterface, ResourceInterface
15
{
16
    use TranslatableTrait {
17
        __construct as private initializeTranslationsCollection;
18
        getTranslation as private doGetTranslation;
19
    }
20
21
    /**
22
     * @var int
23
     */
24
    protected $id;
25
26
    /**
27
     * @var ProductInterface
28
     */
29
    private $product;
30
31
    public function __construct()
32
    {
33
        $this->initializeTranslationsCollection();
34
    }
35
36
    public function __toString()
37
    {
38
        return (string) $this->getId();
39
    }
40
41
    public function getPageTitle(): ?string
42
    {
43
        return $this->getTranslation()->getPageTitle();
0 ignored issues
show
Bug introduced by
The method getPageTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getPageTitle();

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...
44
    }
45
46
    public function setPageTitle(?string $pageTitle): void
47
    {
48
        $this->getTranslation()->setPageTitle($pageTitle);
0 ignored issues
show
Bug introduced by
The method setPageTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
        $this->getTranslation()->/** @scrutinizer ignore-call */ setPageTitle($pageTitle);

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...
49
    }
50
51
    public function getOgTitle(): ?string
52
    {
53
        return $this->getTranslation()->getOgTitle();
0 ignored issues
show
Bug introduced by
The method getOgTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

53
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getOgTitle();

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...
54
    }
55
56
    public function setOgTitle(?string $ogTitle): void
57
    {
58
        $this->getTranslation()->setOgTitle($ogTitle);
0 ignored issues
show
Bug introduced by
The method setOgTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

58
        $this->getTranslation()->/** @scrutinizer ignore-call */ setOgTitle($ogTitle);

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...
59
    }
60
61
    public function getOgDescription(): ?string
62
    {
63
        return $this->getTranslation()->getOgDescription();
0 ignored issues
show
Bug introduced by
The method getOgDescription() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. Did you maybe mean getDescription()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getOgDescription();

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...
64
    }
65
66
    public function setOgDescription(?string $ogDescription): void
67
    {
68
        $this->getTranslation()->setOgDescription($ogDescription);
0 ignored issues
show
Bug introduced by
The method setOgDescription() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. Did you maybe mean setDescription()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
        $this->getTranslation()->/** @scrutinizer ignore-call */ setOgDescription($ogDescription);

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...
69
    }
70
71
    public function getTwitterTitle(): ?string
72
    {
73
        return $this->getTranslation()->getTwitterTitle();
0 ignored issues
show
Bug introduced by
The method getTwitterTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

73
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getTwitterTitle();

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...
74
    }
75
76
    public function setTwitterTitle(?string $twitterTitle): void
77
    {
78
        $this->getTranslation()->setTwitterTitle($twitterTitle);
0 ignored issues
show
Bug introduced by
The method setTwitterTitle() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

78
        $this->getTranslation()->/** @scrutinizer ignore-call */ setTwitterTitle($twitterTitle);

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...
79
    }
80
81
    public function getTwitterDescription(): ?string
82
    {
83
        return $this->getTranslation()->getTwitterDescription();
0 ignored issues
show
Bug introduced by
The method getTwitterDescription() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

83
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getTwitterDescription();

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...
84
    }
85
86
    public function setTwitterDescription(?string $twitterDescription): void
87
    {
88
        $this->getTranslation()->setTwitterDescription($twitterDescription);
0 ignored issues
show
Bug introduced by
The method setTwitterDescription() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

88
        $this->getTranslation()->/** @scrutinizer ignore-call */ setTwitterDescription($twitterDescription);

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...
89
    }
90
91
    public function getTwitterSite(): ?string
92
    {
93
        return $this->getTranslation()->getTwitterSite();
0 ignored issues
show
Bug introduced by
The method getTwitterSite() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

93
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getTwitterSite();

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...
94
    }
95
96
    public function setTwitterSite(?string $twitterSite): void
97
    {
98
        $this->getTranslation()->setTwitterSite($twitterSite);
0 ignored issues
show
Bug introduced by
The method setTwitterSite() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
        $this->getTranslation()->/** @scrutinizer ignore-call */ setTwitterSite($twitterSite);

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...
99
    }
100
101
    public function getExtraTags(): ?string
102
    {
103
        return $this->getTranslation()->getExtraTags();
0 ignored issues
show
Bug introduced by
The method getExtraTags() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

103
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getExtraTags();

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...
104
    }
105
106
    public function setExtraTags(?string $extraTags): void
107
    {
108
        $this->getTranslation()->setExtraTags($extraTags);
0 ignored issues
show
Bug introduced by
The method setExtraTags() does not exist on Sylius\Component\Core\Mo...uctTranslationInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

108
        $this->getTranslation()->/** @scrutinizer ignore-call */ setExtraTags($extraTags);

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...
109
    }
110
111
    public function getId()
112
    {
113
        return $this->id;
114
    }
115
116
    public function setId(?int $id): void
117
    {
118
        $this->id = $id;
119
    }
120
121
    /**
122
     * @return ProductSeoTranslation
123
     */
124
    public function getTranslation(?string $locale = null): TranslationInterface
125
    {
126
        /** @var ProductTranslationInterface $translation */
127
        $translation = $this->doGetTranslation($locale);
128
129
        return $translation;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $translation returns the type Sylius\Component\Core\Mo...uctTranslationInterface which is incompatible with the documented return type JoppeDc\SyliusBetterSeoP...y\ProductSeoTranslation.
Loading history...
130
    }
131
132
    public function getProduct(): ?ProductInterface
133
    {
134
        return $this->product;
135
    }
136
137
    public function setProduct(?ProductInterface $product): void
138
    {
139
        $this->product = $product;
140
    }
141
142
    protected function createTranslation(): ProductSeoTranslation
143
    {
144
        return new ProductSeoTranslation();
145
    }
146
}
147