Completed
Push — cecil ( 66a45a )
by Arnaud
02:09
created

NewWebsite   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B processCommand() 0 24 6
1
<?php
2
/*
3
 * This file is part of the PHPoole/Cecil 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 Cecil\Command;
12
13
use Cecil\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
                    exit(0);
31
                }
32
            }
33
            $root = __DIR__.'/../../';
34
            if (Plateform::isPhar()) {
35
                $root = Plateform::getPharPath().'/';
36
            }
37
            $this->wlAnnonce('Creating a new website...');
38
            $this->fs->copy($root.'skeleton/config.yml', $this->getPath().'/'.self::CONFIG_FILE, true);
39
            $this->fs->mirror($root.'skeleton/content', $this->getPath().'/content');
40
            $this->fs->mirror($root.'skeleton/layouts', $this->getPath().'/layouts');
41
            $this->fs->mirror($root.'skeleton/static', $this->getPath().'/static');
42
            $this->wlDone('Done!');
43
        } catch (\Exception $e) {
44
            throw new \Exception(sprintf($e->getMessage()));
45
        }
46
    }
47
}
48