AbstractMigration   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A migrate() 0 8 1
migratePlugin() 0 1 ?
A validate() 0 8 2
1
<?php
2
3
namespace GinoPane\BlogTaxonomy\Classes\MigrationCommand\Migrations;
4
5
use Illuminate\Console\Command;
6
use System\Classes\PluginManager;
7
use GinoPane\BlogTaxonomy\Classes\MigrationCommand\MigrationInterface;
8
use GinoPane\BlogTaxonomy\Classes\MigrationCommand\Exceptions\NoPluginException;
9
10
/**
11
 * Class PkleindienstBlogSeriesMigration
12
 *
13
 * @package GinoPane\BlogTaxonomy\Classes\MigrationCommand\Migrations
14
 */
15
abstract class AbstractMigration implements MigrationInterface
16
{
17
    const PLUGIN_NAME = '';
18
19
    /**
20
     * @var Command
21
     */
22
    protected $command;
23
24
    /**
25
     * AbstractMigration constructor.
26
     *
27
     * @param Command $command
28
     *
29
     * @throws NoPluginException
30
     */
31
    public function __construct(Command $command)
32
    {
33
        $this->validate();
34
35
        $this->command = $command;
36
    }
37
38
    /**
39
     * @return void
40
     */
41
    public function migrate()
42
    {
43
        $this->command->alert('Migration from ' . static::PLUGIN_NAME);
44
45
        $this->migratePlugin();
46
47
        $this->command->info('Migration from ' . static::PLUGIN_NAME . ' finished');
48
    }
49
50
    abstract protected function migratePlugin();
0 ignored issues
show
Documentation introduced by
For interfaces and abstract methods it is generally a good practice to add a @return annotation even if it is just @return void or @return null, so that implementors know what to do in the overridden method.

For interface and abstract methods, it is impossible to infer the return type from the immediate code. In these cases, it is generally advisible to explicitly annotate these methods with a @return doc comment to communicate to implementors of these methods what they are expected to return.

Loading history...
51
52
    /**
53
     * @throws NoPluginException
54
     */
55
    protected function validate()
56
    {
57
        $pluginManager = PluginManager::instance();
58
59
        if (!$pluginManager->hasPlugin(static::PLUGIN_NAME)) {
60
            throw new NoPluginException(static::PLUGIN_NAME);
61
        }
62
    }
63
}