Youtube::api()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
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