1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MadWeb\Seoable\Protocols; |
4
|
|
|
|
5
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Url; |
6
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Site; |
7
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Type; |
8
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Title; |
9
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Images; |
10
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Values; |
11
|
|
|
use MadWeb\Seoable\Fields\TwitterCard\Description; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @method TwitterCard setTitleRaw(string $value) |
15
|
|
|
* @method TwitterCard setDescriptionRaw(string $value) |
16
|
|
|
* @method TwitterCard setUrlRaw(string $value) |
17
|
|
|
* @method TwitterCard setSiteRaw(string $value) |
18
|
|
|
* @method TwitterCard setTypeRaw(string $value) |
19
|
|
|
* @method TwitterCard setImagesRaw(array|string $value) |
20
|
|
|
* @method TwitterCard setValuesRaw(array $value) |
21
|
|
|
* @method TwitterCard addValueRaw(string $key, mixed $value) |
22
|
|
|
*/ |
23
|
|
|
class TwitterCard extends Protocol |
24
|
|
|
{ |
25
|
|
|
/** @param array|string $value */ |
26
|
|
|
public function setTitle($value, string $templateKey = ''): self |
27
|
|
|
{ |
28
|
|
|
$this->twitterCardService->setTitle($this->parseValue( |
29
|
|
|
$value, |
30
|
|
|
$templateKey ? new Title($value, $this->model, $templateKey) : Title::class |
31
|
|
|
)); |
32
|
|
|
|
33
|
|
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** @param array|string $value */ |
37
|
|
|
public function setDescription($value, string $templateKey = ''): self |
38
|
|
|
{ |
39
|
|
|
$this->twitterCardService->setDescription($this->parseValue( |
40
|
|
|
$value, |
41
|
|
|
$templateKey ? new Description($value, $this->model, $templateKey) : Description::class |
42
|
|
|
)); |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function setUrl(string $value): self |
48
|
|
|
{ |
49
|
|
|
$this->twitterCardService->setUrl($this->parseValue($value, Url::class)); |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function setSite(string $value): self |
55
|
|
|
{ |
56
|
|
|
$this->twitterCardService->setSite($this->parseValue($value, Site::class)); |
57
|
|
|
|
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function setType(string $value): self |
62
|
|
|
{ |
63
|
|
|
$this->twitterCardService->setType($this->parseValue($value, Type::class)); |
64
|
|
|
|
65
|
|
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** @param array|string $value */ |
69
|
|
|
public function setImages($value): self |
70
|
|
|
{ |
71
|
|
|
$this->twitterCardService->setImages($this->parseValue($value, Images::class)); |
|
|
|
|
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function setValues(array $value): self |
77
|
|
|
{ |
78
|
|
|
foreach ($this->parseValue($value, Values::class) as $item) { |
79
|
|
|
$this->twitterCardService->addValue(...array_values($item)); |
|
|
|
|
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** @param array|string $value */ |
86
|
|
|
public function addValue(string $key, $value): self |
87
|
|
|
{ |
88
|
|
|
$this->twitterCardService->addValue( |
|
|
|
|
89
|
|
|
...array_values( |
|
|
|
|
90
|
|
|
$this->parseValue([compact('key', 'value')], Values::class)[0] |
91
|
|
|
) |
92
|
|
|
); |
93
|
|
|
|
94
|
|
|
return $this; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
protected function getRawFields(): array |
98
|
|
|
{ |
99
|
|
|
return $this->modelSeoData['twitter_card']; |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.