GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3612e9...58a54a )
by Michael
04:00
created

DotSub   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 4
c 3
b 0
f 3
lcom 1
cbo 2
dl 0
loc 34
ccs 16
cts 16
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validateUrl() 0 7 1
A normalizeUrl() 0 5 2
A fakeResponse() 0 11 1
1
<?php
2
/**
3
 * DotSub.php
4
 *
5
 * @package Providers
6
 * @author Michael Pratt <[email protected]>
7
 * @link   http://www.michael-pratt.com/
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Embera\Providers;
14
15
/**
16
 * The dotsub.com Provider
17
 * @link http://dotsub.com/
18
 * @link http://dotsub.com/solutions/oEmbed
19
 */
20
class DotSub extends \Embera\Adapters\Service
21
{
22
    /** inline {@inheritdoc} */
23
    protected $apiUrl = 'http://dotsub.com/services/oembed?format=json';
24
25
    /** inline {@inheritdoc} */
26 2
    protected function validateUrl()
27
    {
28 2
        $this->url->stripQueryString();
29 2
        $this->url->stripLastSlash();
30
31 2
        return (preg_match('~dotsub\.com/view/(?:[a-f0-9]+)-(?:[a-f0-9]+)-(?:[a-f0-9]+)-(?:[a-f0-9]+)-(?:[a-f0-9]+)$~i', $this->url));
32
    }
33
34
    /** inline {@inheritdoc} */
35 2
    protected function normalizeUrl()
36
    {
37 2
        if (preg_match('~/(?:media|view)/([0-9a-f\-]+)~i', $this->url, $matches))
38 2
            $this->url = new \Embera\Url('http://dotsub.com/view/' . $matches['1']);
39 2
    }
40
41
    /** inline {@inheritdoc} */
42 2
    public function fakeResponse()
43
    {
44 2
        $url = str_replace('/view/', '/media/', $this->url);
45
        return array(
46 2
            'type' => 'video',
47 2
            'provider_name' => 'DotSUB',
48 2
            'provider_url' => 'http://dotsub.com',
49 2
            'thumbnail_url' => $url . '/t',
50 2
            'html' => '<iframe src="' . $url . '/e/c?width={width}&height={height}" frameborder="0" width="{width}" height="{height}"></iframe>',
51 2
        );
52
    }
53
}
54
55
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
56