PlaylistsTest::getPlaylistsList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 54

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 54
rs 9.0036
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * This file is a part of nekland youtube api package
5
 *
6
 * (c) Nekland <[email protected]>
7
 *
8
 * For the full license, take a look to the LICENSE file
9
 * on the root directory of this project
10
 */
11
12
namespace Nekland\Tests\Api;
13
14
15
use Nekland\YoutubeApi\Youtube;
16
17
class PlaylistsTest extends TestCase
18
{
19
20
    /**
21
     * @test
22
     */
23 View Code Duplication
    public function shouldReturnYoutubeArrayAsJson()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
    {
25
        $youtube = $this->getYoutubeMock(['get' => $this->getPlaylistsList()]);
26
        /** @var \Nekland\YoutubeApi\Api\Playlists $playlists */
27
        $playlists  = $youtube->api('playlists');
28
29
        $this->assertEquals($playlists->listById('DR7e0DoHZ2Y')['etag'], '"gMjDJfS6nsym0T-NKCXALC_u_rM/OS-dz8DrzAjFW7CsH_RCbY99MJc"');
30
        $this->assertEquals($playlists->getById('DR7e0DoHZ2Y')['id'], 'PLXONb89nemXsCa5-v7kO8qbLnCjG9O80f');
31
        $this->assertEquals($playlists->listBy(['id' => 'DR7e0DoHZ2Y'])['etag'], '"gMjDJfS6nsym0T-NKCXALC_u_rM/OS-dz8DrzAjFW7CsH_RCbY99MJc"');
32
    }
33
34
    private function getPlaylistsList()
35
    {
36
        return <<<JSON
37
{
38
    "kind": "youtube#playlistListResponse",
39
    "etag": "\\"gMjDJfS6nsym0T-NKCXALC_u_rM/OS-dz8DrzAjFW7CsH_RCbY99MJc\\"",
40
    "pageInfo": {
41
        "totalResults": 1,
42
        "resultsPerPage": 1
43
    },
44
    "items": [
45
        {
46
            "kind": "youtube#playlist",
47
            "etag": "\\"gMjDJfS6nsym0T-NKCXALC_u_rM/Ax_bKA8m_sB2PAeyA93DR4_icZE\\"",
48
            "id": "PLXONb89nemXsCa5-v7kO8qbLnCjG9O80f",
49
            "snippet": {
50
                "publishedAt": "2014-07-19T21:10:24.000Z",
51
                "channelId": "UCKTI_JRpt8G14YIwe7isYvw",
52
                "title": "Découvertes",
53
                "description": "",
54
                "thumbnails": {
55
                    "default": {
56
                        "url": "https://i.ytimg.com/vi/KD5fLb-WgBU/default.jpg",
57
                        "width": 120,
58
                        "height": 90
59
                    },
60
                    "medium": {
61
                        "url": "https://i.ytimg.com/vi/KD5fLb-WgBU/mqdefault.jpg",
62
                        "width": 320,
63
                        "height": 180
64
                    },
65
                    "high": {
66
                        "url": "https://i.ytimg.com/vi/KD5fLb-WgBU/hqdefault.jpg",
67
                        "width": 480,
68
                        "height": 360
69
                    },
70
                    "standard": {
71
                        "url": "https://i.ytimg.com/vi/KD5fLb-WgBU/sddefault.jpg",
72
                        "width": 640,
73
                        "height": 480
74
                    },
75
                    "maxres": {
76
                        "url": "https://i.ytimg.com/vi/KD5fLb-WgBU/maxresdefault.jpg",
77
                        "width": 1280,
78
                        "height": 720
79
                    }
80
                },
81
                "channelTitle": "Maxime Veber"
82
            }
83
        }
84
    ]
85
}
86
JSON;
87
    }
88
}
89