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.

Factory::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Halfpastfour\PHPChartJS;
4
5
/**
6
 * Class Factory
7
 * @package Halfpastfour\PHPChartJS
8
 */
9
class Factory
10
{
11
    const BAR            = 'bar';
12
    const BUBBLE         = 'bubble';
13
    const DOUGHNUT       = 'doughnut';
14
    const HORIZONTAL_BAR = 'horizontalBar';
15
    const LINE           = 'line';
16
    const PIE            = 'pie';
17
    const POLAR_AREA     = 'polarArea';
18
    const RADAR          = 'radar';
19
    const SCATTER        = 'scatter';
20
21
    /**
22
     * @param $type
23
     *
24
     * @return Chart
25
     */
26
    public function create($type)
27
    {
28
        $className  = ucfirst($type);
29
        $namespace  = "\\Halfpastfour\\PHPChartJS\\Chart";
30
        $path       = "{$namespace}\\{$className}";
31
        if (! class_exists($path)) {
32
            throw new \InvalidArgumentException("Invalid chart type. {$path} does not exist.");
33
        }
34
35
        return new $path;
36
    }
37
}
38