PlaylistsTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 72
Duplicated Lines 13.89 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 10
loc 72
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldReturnYoutubeArrayAsJson() 10 10 1
A getPlaylistsList() 0 54 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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