Passed
Push — develop ( 6aacf8...6c0b7f )
by BENARD
11:52
created

YoutubeProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getVideo() 0 3 1
1
<?php
2
namespace VideoGamesRecords\CoreBundle\DataProvider;
3
4
use Google\Service\YouTube;
5
use Google\Client;
6
use Google\Service\YouTube\VideoListResponse;
7
8
class YoutubeProvider
9
{
10
    private Youtube $service;
11
12
    /**
13
     * @param string $apiKey
14
     */
15
    public function __construct(string $apiKey)
16
    {
17
        $client = new Client();
18
        $client->addScope(YouTube::YOUTUBE);
19
        $client->setDeveloperKey($apiKey);
20
21
        $this->service = new YouTube($client);
22
    }
23
24
    /**
25
     * @param $videoId
26
     * @return VideoListResponse
27
     */
28
    public function getVideo($videoId): VideoListResponse
29
    {
30
        return $this->service->videos->listVideos('snippet,contentDetails,statistics', ['id' => $videoId]);
31
    }
32
}
33