Video   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 2
cbo 3
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 0 8 2
A toArray() 0 12 1
1
<?php
2
3
namespace LaraComponents\Seo\OpenGraph;
4
5
use LaraComponents\Seo\OpenGraph\Traits\HasUrl;
6
use LaraComponents\Seo\OpenGraph\Traits\HasWidthAndHeight;
7
8
class Video extends Media
9
{
10
    use HasUrl, HasWidthAndHeight;
11
12
    CONST VALID_TYPES = [
13
        'application/x-shockwave-flash',
14
        'video/mp4',
15
        'video/ogg',
16
        'video/webm',
17
    ];
18
19
    public function setType($type)
20
    {
21
        if (in_array($type, Video::VALID_TYPES)) {
22
            $this->type = $type;
23
        }
24
25
        return $this;
26
    }
27
28
    public function toArray()
29
    {
30
        $result = [];
31
32
        $result['og:video'] = $this->getUrl();
33
        $result['og:video:type'] = $this->getType();
34
        $result['og:video:secure_url'] = $this->getSecureUrl();
35
        $result['og:video:width'] = $this->getWidth();
36
        $result['og:video:height'] = $this->getHeight();
37
38
        return array_filter($result);
39
    }
40
}
41