Youtube   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A api() 0 11 3
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\YoutubeApi;
13
14
use Nekland\BaseApi\Api;
15
use Nekland\BaseApi\Http\ClientInterface;
16
use Nekland\YoutubeApi\Http\HttpClient;
17
18
class Youtube extends Api
19
{
20
    /**
21
     * @param ClientInterface $httpClient
22
     */
23
    public function __construct(ClientInterface $httpClient=null)
24
    {
25
        if (null === $httpClient) {
26
            parent::__construct(new HttpClient());
27
        } else {
28
            parent::__construct($httpClient);
29
        }
30
    }
31
32
    /**
33
     * @param string $name
34
     * @return Api\AbstractApi
35
     * @throws \InvalidArgumentException
36
     */
37
    public function api($name)
38
    {
39
        switch($name) {
40
            case 'videos':
41
                return new \Nekland\YoutubeApi\Api\Videos($this);
42
            case 'playlists':
43
                return new \Nekland\YoutubeApi\Api\Playlists($this);
44
            default:
45
                throw new \InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name));
46
        }
47
    }
48
}
49