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

CKEditorScriptHandler   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 64.29%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 49
ccs 18
cts 28
cp 0.6429
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A install() 0 8 1
C createCommand() 0 29 7
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