Passed
Branch master (837534)
by Oguzhan
04:07 queued 33s
created

Artist   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 75%

Importance

Changes 5
Bugs 1 Features 2
Metric Value
c 5
b 1
f 2
dl 0
loc 83
wmc 8
lcom 1
cbo 4
ccs 18
cts 24
cp 0.75
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getParent() 0 4 1
A getByGuid() 0 4 1
A setParent() 0 4 1
A getByName() 0 4 1
A transformSingle() 0 12 1
A transformCollection() 0 9 2
A transform() 0 4 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: PBX_g33k
5
 * Date: 22-May-16
6
 * Time: 22:14
7
 */
8
9
namespace Pbxg33k\MusicInfo\Service\VocaDB\Endpoint;
10
11
use Doctrine\Common\Collections\ArrayCollection;
12
use Pbxg33k\MusicInfo\Model\Artist as ArtistModel;
13
use Pbxg33k\MusicInfo\Model\IMusicServiceEndpoint;
14
use Pbxg33k\VocaDB\Artist as ArtistEndpoint;
15
16
class Artist extends ArtistEndpoint implements IMusicServiceEndpoint
17
{
18
    /**
19
     *
20
     */
21
    const DATA_SOURCE = 'vocadb';
22
23
    /**
24
     * @return mixed
25
     */
26
    public function getParent()
27
    {
28
        // TODO: Implement getApiService() method.
29
    }
30
31
    /**
32
     * Aliases getById
33
     *
34
     * @param $guid
35
     *
36
     * @return mixed
37
     */
38
    public function getByGuid($guid)
39
    {
40
        return $this->getById($guid);
41
    }
42
43
    /**
44
     * @return mixed
45
     */
46
    public function setParent($apiService)
47
    {
48
        // TODO: Implement setApiService() method.
49
    }
50
51 3
    public function getByName($name)
52
    {
53 3
        return $this->transform(parent::getByName($name)); // TODO: Change the autogenerated stub
54
    }
55
56
    /**
57
     * @param $raw
58
     *
59
     * @return ArtistModel
60
     */
61 3
    public function transformSingle($raw)
62
    {
63 3
        $object = new ArtistModel;
64
        $object
65 3
            ->setId($raw->getId())
66 3
            ->setName($raw->getName())
67 3
            ->setType($raw->getArtistType())
68 3
            ->setDataSource(self::DATA_SOURCE)
69 3
            ->setRawData($raw);
70
71 3
        return $object;
72
    }
73
74
    /**
75
     * @param $raw
76
     *
77
     * @return ArrayCollection
78
     */
79 3
    public function transformCollection($raw)
80
    {
81 3
        $collection = new ArrayCollection();
82 3
        foreach ($raw->collection as $artist) {
83 3
            $collection->add($this->transformSingle($artist));
84 3
        }
85
86 3
        return $collection;
87
    }
88
89
    /**
90
     * @param $raw
91
     *
92
     * @return ArrayCollection
93
     */
94 3
    public function transform($raw)
95
    {
96 3
        return $this->transformCollection($raw);
97
    }
98
}