Completed
Push — master ( 6077fa...f4e20a )
by Pascal
02:40
created

ModelCommand::execute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php
2
namespace Atog\Api\Console;
3
4
use Symfony\Component\Console\Input\InputInterface;
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
/**
8
 * Class ModelCommand
9
 * @package Atog\Console
10
 */
11
class ModelCommand extends AbstractScaffoldingCommand
12
{
13
    /**
14
     * @var string
15
     */
16
    protected $type = 'model';
17
18
    /**
19
     * Execute command
20
     * @param \Symfony\Component\Console\Input\InputInterface   $input
21
     * @param \Symfony\Component\Console\Output\OutputInterface $output
22
     * @return void
23
     */
24 2
    protected function execute(InputInterface $input, OutputInterface $output)
25
    {
26 2
        if ($this->getApplication() instanceof Application) {
27 2
            $this->createFileTemplate($input, $output, $this->getApplication()->modelPath());
28 2
        }
29 2
    }
30
31
    /**
32
     * File Template
33
     * @param string $namespace
34
     * @param string $name
35
     * @param string $topNSPart
36
     * @return string
37
     */
38 2
    protected function template($namespace, $name, $topNSPart = "Models")
39
    {
40 2
        $className = str_plural($name);
41 2
        $namespace = "{$namespace}\\{$topNSPart}";
42
43
        return <<< EOT
44
<?php
45
namespace $namespace;
46
47
use Atog\Api\Model;
48
49
/**
50 2
 * Class $className
51 2
 * @package $namespace
52
 */
53 2
class $className extends Model
54
{
55
}
56
57 2
EOT;
58
    }
59
}
60