Passed
Pull Request — master (#9)
by
unknown
03:52
created

ProductSeo::getOgDescription()   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 0
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 getOgType(): ?string
72
    {
73
        return $this->getTranslation()->getOgType();
0 ignored issues
show
Bug introduced by
The method getOgType() 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 */ getOgType();

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 setOgType(?string $ogType): void
77
    {
78
        $this->getTranslation()->setOgType($ogType);
0 ignored issues
show
Bug introduced by
The method setOgType() 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 */ setOgType($ogType);

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 getTwitterCard(): ?string
82
    {
83
        return $this->getTranslation()->getTwitterCard();
0 ignored issues
show
Bug introduced by
The method getTwitterCard() 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 */ getTwitterCard();

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 setTwitterCard(?string $twitterCard): void
87
    {
88
        $this->getTranslation()->setTwitterCard($twitterCard);
0 ignored issues
show
Bug introduced by
The method setTwitterCard() 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 */ setTwitterCard($twitterCard);

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 getTwitterTitle(): ?string
92
    {
93
        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

93
        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...
94
    }
95
96
    public function setTwitterTitle(?string $twitterTitle): void
97
    {
98
        $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

98
        $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...
99
    }
100
101
    public function getTwitterDescription(): ?string
102
    {
103
        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

103
        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...
104
    }
105
106
    public function setTwitterDescription(?string $twitterDescription): void
107
    {
108
        $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

108
        $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...
109
    }
110
111
    public function getTwitterSite(): ?string
112
    {
113
        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

113
        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...
114
    }
115
116
    public function setTwitterSite(?string $twitterSite): void
117
    {
118
        $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

118
        $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...
119
    }
120
121
    public function getImage(): ?string
122
    {
123
        return $this->getTranslation()->getImage();
0 ignored issues
show
Bug introduced by
The method getImage() 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

123
        return $this->getTranslation()->/** @scrutinizer ignore-call */ getImage();

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...
124
    }
125
126
    public function setImage(?string $image): void
127
    {
128
        $this->getTranslation()->setImage($image);
0 ignored issues
show
Bug introduced by
The method setImage() 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

128
        $this->getTranslation()->/** @scrutinizer ignore-call */ setImage($image);

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...
129
    }
130
131
    public function getId()
132
    {
133
        return $this->id;
134
    }
135
136
    public function setId(?int $id): void
137
    {
138
        $this->id = $id;
139
    }
140
141
    /**
142
     * @return ProductSeoTranslation
143
     */
144
    public function getTranslation(?string $locale = null): TranslationInterface
145
    {
146
        /** @var ProductTranslationInterface $translation */
147
        $translation = $this->doGetTranslation($locale);
148
149
        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...
150
    }
151
152
    public function getProduct(): ?ProductInterface
153
    {
154
        return $this->product;
155
    }
156
157
    public function setProduct(?ProductInterface $product): void
158
    {
159
        $this->product = $product;
160
    }
161
162
    protected function createTranslation(): ProductSeoTranslation
163
    {
164
        return new ProductSeoTranslation();
165
    }
166
}
167