Passed
Push — master ( 730218...5f362f )
by Matthias
10:39 queued 08:10
created

Audio   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 30.76%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 58
ccs 4
cts 13
cp 0.3076
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getProperties() 0 19 4
1
<?php
2
3
namespace Fusonic\OpenGraph\Elements;
4
5
use Fusonic\OpenGraph\Property;
6
7
/**
8
 * An Open Graph audio element.
9
 */
10
class Audio extends ElementBase
11
{
12
    /**
13
     * The URL of an audio resource associated with the object.
14
     *
15
     * @var string
16
     */
17
    public $url;
18
19
    /**
20
     * An alternate URL to use if an audio resource requires HTTPS.
21
     *
22
     * @var string
23
     */
24
    public $secureUrl;
25
26
    /**
27
     * The MIME type of an audio resource associated with the object.
28
     *
29
     * @var type
30
     */
31
    public $type;
32
33
    /**
34
     * @param   string      $url            URL to the audio file.
35
     */
36 1
    public function __construct($url)
37
    {
38 1
        parent::__construct();
39
40 1
        $this->url = $url;
41 1
    }
42
43
    /**
44
     * Gets all properties set on this element.
45
     *
46
     * @return  array|Property[]
47
     */
48
    public function getProperties()
49
    {
50
        $properties = [];
51
52
        // URL must precede all other properties
53
        if ($this->url !== null) {
54
            $properties[] = new Property(Property::AUDIO_URL, $this->url);
55
        }
56
57
        if ($this->secureUrl !== null) {
58
            $properties[] = new Property(Property::AUDIO_SECURE_URL, $this->secureUrl);
59
        }
60
61
        if ($this->type !== null) {
62
            $properties[] = new Property(Property::AUDIO_TYPE, $this->type);
63
        }
64
65
        return $properties;
66
    }
67
}
68