Completed
Push — master ( cfe8fe...f9982c )
by Rougin
04:59
created

InstallWildfireCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 5
Bugs 2 Features 0
Metric Value
c 5
b 2
f 0
dl 0
loc 16
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Rougin\Combustor\Commands;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
use Rougin\Combustor\Common\Tools;
9
use Rougin\Combustor\Common\Commands\InstallCommand;
10
11
/**
12
 * Install Wildfire Command
13
 *
14
 * Installs Wildfire for CodeIgniter
15
 * 
16
 * @package Combustor
17
 * @author  Rougin Royce Gutib <[email protected]>
18
 */
19
class InstallWildfireCommand extends InstallCommand
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $library = 'wildfire';
25
26
    /**
27
     * Executes the command.
28
     * 
29
     * @param  \Symfony\Component\Console\Input\InputInterface   $input
30
     * @param  \Symfony\Component\Console\Output\OutputInterface $output
31
     * @return object|\Symfony\Component\Console\Output\OutputInterface
32
     */
33 12
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35 12
        $this->addLibrary('wildfire');
36
37 12
        $file = fopen(APPPATH . 'libraries/Wildfire.php', 'wb');
38 12
        $wildfire = $this->renderer->render('Libraries/Wildfire.template');
39
40 12
        file_put_contents(APPPATH . 'libraries/Wildfire.php', $wildfire);
41 12
        fclose($file);
42
43 12
        Tools::ignite();
44
45 12
        $message = 'Wildfire is now installed successfully!';
46
47 12
        return $output->writeln('<info>' . $message . '</info>');
48
    }
49
}
50