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.

AmCharts   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validateUrl() 0 5 1
A normalizeUrl() 0 9 2
A fakeResponse() 0 16 1
1
<?php
2
/**
3
 * AmCharts.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 AmCharts Live Charts  Provider
17
 * @link http://live.amcharts.com
18
 */
19
class AmCharts extends \Embera\Adapters\Service
20
{
21
    /** inline {@inheritdoc} */
22
    protected $apiUrl = 'http://live.amcharts.com/oembed/?format=json';
23
24
    /** inline {@inheritdoc} */
25
    protected function validateUrl()
26
    {
27
        $this->url->invalidPattern('amcharts\.com/new');
28
        return (preg_match('~live\.amcharts\.com/([^ /]+)/?$~i', $this->url));
29
    }
30
31
    /** inline {@inheritdoc} */
32
    protected function normalizeUrl()
33
    {
34
        $this->url->stripQueryString();
35
        $this->url->convertToHttp();
36
37
        if (preg_match('~amcharts\.com/([^ /]+)(/edit/?)?~i', $this->url, $matches)) {
38
            $this->url = new \Embera\Url('http://live.amcharts.com/' . $matches['1'] . '/');
39
        }
40
    }
41
42
    /** inline {@inheritdoc} */
43
    public function fakeResponse()
44
    {
45
        preg_match('~amcharts\.com/([^ /]+)~i', $this->url, $matches);
46
        $url = 'http://live.amcharts.com/' . $matches['1'];
47
48
        return array(
49
            'type' => 'rich',
50
            'provider_name' => 'amCharts',
51
            'provider_url' => 'http://www.amcharts.com/',
52
            'thumbnail_url' => 'http://generated.amcharts.com/' . substr($matches['1'], 0, 2) . '/' . $matches['1'] . '-full.png',
53
            'thumbnail_width' => 404,
54
            'thumbnail_height' => 300,
55
            'canonical' => $url . '/',
56
            'html' => '<iframe width="{width}" height="{height}" src="' . $url . '/embed/" frameborder="0"></iframe>',
57
        );
58
    }
59
}
60
61
?>
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...
62