Passed
Push — 4-cactus ( 89e7fd...01e702 )
by Stefano
03:47 queued 28s
created

BEdita/Core/src/Command/TreeRecoverCommand.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * BEdita, API-first content management framework
4
 * Copyright 2022 Atlas Srl, Chialab Srl
5
 *
6
 * This file is part of BEdita: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published
8
 * by the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
12
 */
13
14
namespace BEdita\Core\Command;
15
16
use Cake\Console\Arguments;
17
use Cake\Console\Command;
18
use Cake\Console\ConsoleIo;
19
use Cake\Console\ConsoleOptionParser;
20
21
/**
22
 * Command to recover tree.
23
 *
24
 * @since 4.0.0
25
 * @property \BEdita\Core\Model\Table\TreesTable $Trees
26
 */
27
class TreeRecoverCommand extends Command
28
{
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public $modelClass = 'Trees';
33
34
    /**
35
     * {@inheritDoc}
36
     *
37
     * @codeCoverageIgnore
38
     */
39
    public static function defaultName(): string
40
    {
41
        return 'tree recover';
42
    }
43
44
    /**
45
     * {@inheritDoc}
46
     *
47
     * @codeCoverageIgnore
48
     */
49
    public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser
50
    {
51
        return parent::buildOptionParser($parser)
52
            ->setDescription('Recover objects\' tree from corruption.');
53
    }
54
55
    /**
56
     * Implement this method with your command's logic.
57
     *
58
     * @param \Cake\Console\Arguments $args The command arguments.
59
     * @param \Cake\Console\ConsoleIo $io The console I/O.
60
     * @return int Exit code.
61
     */
62
    public function execute(Arguments $args, ConsoleIo $io): int
63
    {
64
        $io->out('=====> <info>Beginning tree recovery...</info>');
65
66
        $start = microtime(true);
67
        $this->Trees->recover();
0 ignored issues
show
The method recover() does not exist on BEdita\Core\Model\Table\TreesTable. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
        $this->Trees->/** @scrutinizer ignore-call */ 
68
                      recover();
Loading history...
68
        $end = microtime(true);
69
70
        $io->out(sprintf('=====> <success>Tree recovery completed</success> (took <info>%f</info> seconds)', $end - $start));
71
72
        return static::CODE_SUCCESS;
73
    }
74
}
75