Completed
Push — master ( 4d59b5...976443 )
by Eric
22:25
created

CKEditorScriptHandler::install()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the Ivory CKEditor package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\CKEditorBundle\Composer;
13
14
use Composer\Script\CommandEvent;
15
use Composer\Script\Event;
16
use Sensio\Bundle\DistributionBundle\Composer\ScriptHandler;
17
18
/**
19
 * @author GeLo <[email protected]>
20
 */
21
class CKEditorScriptHandler extends ScriptHandler
22
{
23
    /**
24
     * @param CommandEvent|Event $event
25
     */
26 20
    public static function install($event)
27
    {
28 20
        static::executeCommand(
29 18
            $event,
30 20
            static::getConsoleDir($event, 'Install CKEditor'),
31 20
            static::createCommand($event)
32 16
        );
33 20
    }
34
35
    /**
36
     * @param CommandEvent|Event $event
37
     *
38
     * @return string
39
     */
40 20
    protected static function createCommand($event)
41
    {
42 20
        $extra = $event->getComposer()->getPackage()->getExtra();
43 20
        $command = 'ckeditor:install';
44
45 20
        if (isset($extra['ckeditor-path'])) {
46
            $command .= ' '.$extra['ckeditor-path'];
47
        }
48
49 20
        if (isset($extra['ckeditor-release'])) {
50
            $command .= ' --release='.$extra['ckeditor-release'];
51
        }
52
53 20
        if (isset($extra['ckeditor-tag'])) {
54
            $command .= ' --tag='.$extra['ckeditor-tag'];
55
        }
56
57 20
        if (isset($extra['ckeditor-clear'])) {
58 20
            $command .= ' --clear='.$extra['ckeditor-clear'];
59 16
        }
60
61 20
        if (isset($extra['ckeditor-exclude'])) {
62
            foreach ($extra['ckeditor-exclude'] as $exclude) {
63
                $command .= ' --exclude='.$exclude;
64
            }
65
        }
66
67 20
        return $command;
68
    }
69
}
70