Audio::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace LaraComponents\Seo\OpenGraph;
4
5
use LaraComponents\Seo\OpenGraph\Traits\HasUrl;
6
7
class Audio extends Media
8
{
9
    use HasUrl;
10
11
    CONST VALID_TYPES = [
12
        'application/x-shockwave-flash',
13
        'audio/mpeg',
14
        'audio/mp4',
15
        'audio/ogg',
16
    ];
17
18
    public function setType($type)
19
    {
20
        if (in_array($type, Audio::VALID_TYPES)) {
21
            $this->type = $type;
22
        }
23
24
        return $this;
25
    }
26
27
    public function toArray()
28
    {
29
        $result = [];
30
31
        $result['og:audio'] = $this->getUrl();
32
        $result['og:audio:type'] = $this->getType();
33
        $result['og:audio:secure_url'] = $this->getSecureUrl();
34
35
        return array_filter($result);
36
    }
37
}
38