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.

MigrationNameParser::getActionObject()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Dami\Migration;
4
5
use Stringy\StaticStringy as S;
6
7
class MigrationNameParser
8
{
9
    private $migrationName;
10
    private $action;
11
    private $actionObject;
12
    private $model;
13
    private $validActions = array('create', 'add', 'drop', 'remove');
14
    private $validActionObjects = array('table', 'column', 'index');
15
16
    /**
17
     * Sets a migration name.
18
     *
19
     * @param string $migrationName A migration name.
20
     *
21
     * @return void
22
     */
23
    public function setMigrationName($migrationName)
24
    {
25
        $this->migrationName = $migrationName;
26
        $migrationNameAsUnderscoreSrtring = S::underscored($migrationName);
27
        $items = explode('_', $migrationNameAsUnderscoreSrtring);
28
        if (count($items) >= 3) {
29
            $this->action = in_array($items[0], $this->validActions)
30
                ? $items[0]
31
                : null;
32
            $this->actionObject = in_array($items[1], $this->validActionObjects)
33
                ? $items[1]
34
                : null;
35
            $this->model = str_replace($items[0] . '_' . $items[1] . '_', '', $migrationNameAsUnderscoreSrtring);
36
        }
37
    }
38
39
    /**
40
     * Gets an action name of migration.
41
     *
42
     * @return string Action name.
43
     */
44
    public function getAction()
45
    {
46
        return $this->action;
47
    }
48
49
    /**
50
     * Gets an object  of action.
51
     *
52
     * @return string Object action name.
53
     */
54
    public function getActionObject()
55
    {
56
        return $this->actionObject;
57
    }
58
59
    /**
60
     * Gets a model name of migration.
61
     *
62
     * @return string Model name.
63
     */
64
    public function getModel()
65
    {
66
        return $this->model;
67
    }
68
}
69