Total Complexity | 7 |
Total Lines | 82 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class HrefLang extends Extension |
||
14 | { |
||
15 | /** |
||
16 | * Name of Namescapce |
||
17 | */ |
||
18 | const NAMESPACE_NAME = 'xhtml'; |
||
19 | |||
20 | /** |
||
21 | * Namespace URL |
||
22 | */ |
||
23 | const NAMESPACE_URL = 'http://www.w3.org/1999/xhtml'; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $hrefLang = []; |
||
29 | |||
30 | /** |
||
31 | * @param string $hrefLang |
||
32 | * @param string $href |
||
33 | * |
||
34 | * @return self |
||
35 | */ |
||
36 | public function __construct(string $hrefLang, string $href) |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param string $hrefLang |
||
43 | * @param string $href |
||
44 | * |
||
45 | * @return self |
||
46 | */ |
||
47 | public function addHrefLang(string $hrefLang, string $href): self |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | public function toArray(): array |
||
65 | { |
||
66 | $array = [ |
||
67 | '_namespace' => static::NAMESPACE_NAME, |
||
68 | '_element' => 'link', |
||
69 | 'link' => [] |
||
70 | ]; |
||
71 | |||
72 | foreach ($this->getHrefLangs() as $hreflang => $href) { |
||
73 | $array['link'][] = [ |
||
74 | '_attributes' => [ |
||
75 | 'rel' => 'alternate', |
||
76 | 'hreflang' => $hreflang, |
||
77 | 'href' => $href |
||
78 | ] |
||
79 | ]; |
||
80 | } |
||
81 | |||
82 | return $array; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | */ |
||
88 | public function getHrefLangs(): array |
||
95 | } |
||
96 | } |
||
97 |