Code Duplication    Length = 12-13 lines in 3 locations

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

@@ 86-98 (lines=13) @@
83
     * @return ArrayCollection
84
     * @throws \Exception
85
     */
86
    public function transformCollection($raw)
87
    {
88
        $collection = new ArrayCollection();
89
        if (is_object($raw) && isset($raw->albums)) {
90
            foreach ($raw->albums->items as $album) {
91
                $collection->add($this->transformSingle($album));
92
            }
93
94
            return $collection;
95
        }
96
97
        throw new \Exception('Transform failed');
98
    }
99
100
    /**
101
     * Transform to models

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

@@ 153-164 (lines=12) @@
150
     * @return ArrayCollection
151
     * @throws \Exception
152
     */
153
    public function transformCollection($raw)
154
    {
155
        $collection = new ArrayCollection();
156
        if (is_object($raw) && isset($raw->artists)) {
157
            foreach ($raw->artists->items as $artist) {
158
                $collection->add($this->transformSingle($artist));
159
            }
160
161
            return $collection;
162
        }
163
        throw new \Exception('Transform failed');
164
    }
165
166
    /**
167
     * @param $raw

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

@@ 84-96 (lines=13) @@
81
     * @return ArrayCollection
82
     * @throws \Exception
83
     */
84
    public function transformCollection($raw)
85
    {
86
        $collection = new ArrayCollection();
87
        if (is_object($raw) && isset($raw->tracks)) {
88
            foreach ($raw->tracks->items as $track) {
89
                $collection->add($this->transformSingle($track));
90
            }
91
92
            return $collection;
93
        }
94
95
        throw new TransformationException('Expected object');
96
    }
97
98
    /**
99
     * @param $raw