Completed
Pull Request — master (#1)
by Rougin
02:21
created

ResetCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 23.08%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 38
ccs 3
cts 13
cp 0.2308
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 4 1
A execute() 0 18 2
1
<?php
2
3
namespace Rougin\Refinery\Commands;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Reset Command
10
 *
11
 * Resets all migrations.
12
 *
13
 * @package Refinery
14
 * @author  Rougin Royce Gutib <[email protected]>
15
 */
16
class ResetCommand extends AbstractCommand
17
{
18
    /**
19
     * Sets the configurations of the specified command.
20
     *
21
     * @return void
22
     */
23 3
    protected function configure()
24
    {
25 3
        $this->setName('reset')->setDescription('Resets all migrations');
26 3
    }
27
28
    /**
29
     * Executes the command.
30
     *
31
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
32
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
33
     * @return object|\Symfony\Component\Console\Output\OutputInterface
34
     */
35
    protected function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $current = $this->getLatestVersion();
38
39
        if ($current <= 0) {
40
            return $output->writeln('<info>Database\'s version is now in 0.</info>');
41
        }
42
43
        $this->toggleMigration(true);
44
        $this->changeVersion($current, 0);
45
46
        $this->codeigniter->load->library('migration');
0 ignored issues
show
Bug introduced by
The property load does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
47
        $this->codeigniter->migration->current();
0 ignored issues
show
Bug introduced by
The property migration does not seem to exist in CI_Controller.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
48
49
        $this->toggleMigration();
50
51
        return $output->writeln('<info>Database has been resetted.</info>');
52
    }
53
}
54