Completed
Push — master ( 071097...7934b9 )
by
unknown
09:17
created

VimeoProvider::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MediaMonks\SonataMediaBundle\Provider;
4
5
class VimeoProvider extends AbstractOembedProvider implements OembedProviderInterface
6
{
7
    const URL_OEMBED = 'https://vimeo.com/api/oembed.json?url=http://vimeo.com/%s';
8
9
    /**
10
     * @param $value
11
     * @return string
12
     * @throws \Exception
13
     */
14 1
    public function parseProviderReference($value)
15
    {
16 1
        if (strpos($value, 'vimeo.com')) {
17 1
            $urlParts = explode('/', parse_url($value, PHP_URL_PATH));
18 1
            foreach ($urlParts as $urlPart) {
19 1
                if (ctype_digit($urlPart)) {
20 1
                    return $urlPart;
21
                }
22
            }
23
        }
24
25 1
        return $value;
26
    }
27
28
    /**
29
     * @param string $id
30
     * @return string
31
     */
32 1
    public function getOembedUrl($id)
33
    {
34 1
        return sprintf(self::URL_OEMBED, $id);
35
    }
36
37
    /**
38
     * @return string
39
     */
40 8
    public function getIcon()
41
    {
42 8
        return 'fa fa-vimeo';
43
    }
44
45
    /**
46
     * @return string
47
     */
48 8
    public function getName()
49
    {
50 8
        return 'vimeo';
51
    }
52
53
    /**
54
     * @return string
55
     */
56 1
    public function getType()
57
    {
58 1
        return AbstractProvider::TYPE_VIDEO;
59
    }
60
}
61