Completed
Push — commands ( 4282a7 )
by Arnaud
04:21
created

NewWebsite::processCommand()   B

Complexity

Conditions 6
Paths 35

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 8.8977
c 0
b 0
f 0
cc 6
nc 35
nop 0
1
<?php
2
/*
3
 * This file is part of the PHPoole package.
4
 *
5
 * Copyright (c) Arnaud Ligny <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PHPoole\Command;
12
13
use PHPoole\Util\Plateform;
14
use Zend\Console\Prompt\Confirm;
15
16
class NewWebsite extends AbstractCommand
17
{
18
    /**
19
     * @var bool
20
     */
21
    protected $force;
22
23
    public function processCommand()
24
    {
25
        $this->force = $this->getRoute()->getMatchedParam('force', false);
26
27
        try {
28
            if ($this->fs->exists($this->getPath().'/'.self::CONFIG_FILE) && !$this->force) {
29
                if (!Confirm::prompt('Website already exists. Do you want to override it? [y/n]', 'y', 'n')) {
30
                    // throw new \Exception(sprintf('Config file already exists: "%s".', $this->getPath().'/'.self::CONFIG_FILE));
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
31
                    exit(0);
32
                }
33
            }
34
            $root = __DIR__.'/../../';
35
            if (Plateform::isPhar()) {
36
                $root = Plateform::getPharPath().'/';
37
            }
38
            $this->wlAnnonce('Creating a new website...');
39
            $this->fs->copy($root.'skeleton/phpoole.yml', $this->getPath().'/'.self::CONFIG_FILE, true);
40
            $this->fs->mirror($root.'skeleton/content', $this->getPath().'/content');
41
            $this->fs->mirror($root.'skeleton/layouts', $this->getPath().'/layouts');
42
            $this->fs->mirror($root.'skeleton/static', $this->getPath().'/static');
43
            $this->wlDone('Done!');
44
        } catch (\Exception $e) {
45
            throw new \Exception(sprintf($e->getMessage()));
46
        }
47
    }
48
}
49