Passed
Push — master ( dcae43...a2c429 )
by Warrick
01:37
created

Music::format()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TPG\Pcflib\Categories;
4
5
class Music extends Category
6
{
7
    const FORMAT_CD = 'CD';
8
    const FORMAT_CASSETTE = 'Cassette';
9
    const FORMAT_LP = 'LP';
10
    const FORMAT_DVD = 'DVD';
11
    const FORMAT_DOWNLOADABLE = 'Downloadable';
12
    const FORMAT_STREAMING = 'Streaming';
13
14
    protected $requiredAttributes = [
15
        'Format'
16
    ];
17
18
    public function format(string $format)
19
    {
20
        $this->attributes['Format'] = $format;
21
        return $this;
22
    }
23
24
    public function artist(string $artist)
25
    {
26
        $this->attributes['Artist'] = $artist;
27
        return $this;
28
    }
29
30
    public function label(string $label)
31
    {
32
        $this->attributes['Label'] = $label;
33
        return $this;
34
    }
35
36
    public function releaseDate($year, int $month, int $day)
37
    {
38
        $date = $year;
39
40
        if (get_class($year) !== \DateTime::class && !is_subclass_of($year, \DateTime::class)) {
41
42
            $date = new \DateTime(implode('-', [$year, $month, $day]));
43
        }
44
45
        $this->attributes['ReleaseDate'] = $date->format('Y-m-d');
46
        return $this;
47
    }
48
}