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

ModelCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 0
cbo 2
dl 0
loc 49
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 6 2
A template() 0 21 1
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