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

YoutubeProvider::getVideo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 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