Code Duplication    Length = 12-13 lines in 3 locations

src/Service/Spotify/Endpoint/Album.php 1 location

@@ 73-85 (lines=13) @@
70
     * @return ArrayCollection
71
     * @throws \Exception
72
     */
73
    public function transformCollection($raw)
74
    {
75
        $collection = new ArrayCollection();
76
        if (is_object($raw) && isset($raw->albums)) {
77
            foreach ($raw->albums->items as $album) {
78
                $collection->add($this->transformSingle($album));
79
            }
80
81
            return $collection;
82
        }
83
84
        throw new \Exception('Transform failed');
85
    }
86
87
    /**
88
     * Transform to models

src/Service/Spotify/Endpoint/Artist.php 1 location

@@ 137-148 (lines=12) @@
134
     * @return ArrayCollection
135
     * @throws \Exception
136
     */
137
    public function transformCollection($raw)
138
    {
139
        $collection = new ArrayCollection();
140
        if (is_object($raw) && isset($raw->artists)) {
141
            foreach ($raw->artists->items as $artist) {
142
                $collection->add($this->transformSingle($artist));
143
            }
144
145
            return $collection;
146
        }
147
        throw new \Exception('Transform failed');
148
    }
149
150
    /**
151
     * @param $raw

src/Service/Spotify/Endpoint/Track.php 1 location

@@ 70-82 (lines=13) @@
67
     * @return ArrayCollection
68
     * @throws \Exception
69
     */
70
    public function transformCollection($raw)
71
    {
72
        $collection = new ArrayCollection();
73
        if (is_object($raw) && isset($raw->tracks)) {
74
            foreach ($raw->tracks->items as $track) {
75
                $collection->add($this->transformSingle($track));
76
            }
77
78
            return $collection;
79
        }
80
81
        throw new \Exception('Transformation failed');
82
    }
83
84
    /**
85
     * @param $raw