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.

FileNameParser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 49
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getVersion() 0 4 1
A getMigrationName() 0 4 1
A getMigrationClassName() 0 4 1
1
<?php
2
3
namespace Dami\Migration;
4
5
use Stringy\StaticStringy as S;
6
7
class FileNameParser
8
{
9
    private $version;
10
11
    /**
12
     * Constructor.
13
     *
14
     * @param string $filename Filename of migration.
15
     */
16
    public function __construct($filename)
17
    {
18
        $items = explode('_', $filename);
19
        $this->version = $items[0];
20
21
        $this->name = ltrim($filename, $this->version . '_');
0 ignored issues
show
Bug introduced by
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
22
        $this->name = basename($this->name, '.php');
23
        $this->className = S::upperCamelize($this->name) . 'Migration';
0 ignored issues
show
Bug introduced by
The property className does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
    }
25
26
    /**
27
     * Get version of migration.
28
     *
29
     * @return string
30
     */
31
    public function getVersion()
32
    {
33
        return $this->version;
34
    }
35
36
    /**
37
     * Get name of migration.
38
     *
39
     * @return string
40
     */
41
    public function getMigrationName()
42
    {
43
        return $this->name;
44
    }
45
46
    /**
47
     * Get class name of migration.
48
     *
49
     * @return string
50
     */
51
    public function getMigrationClassName()
52
    {
53
        return $this->className;
54
    }
55
}
56