Test Setup Failed
Push — master ( 616e84...29d7f6 )
by Php Easy Api
03:53
created

Client::create()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 37
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 19
nc 8
nop 0
dl 0
loc 37
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Console\Source\Client;
4
5
use Resta\Console\ConsoleOutputter;
6
use Resta\Console\ConsoleListAccessor;
7
use Resta\Foundation\PathManager\StaticPathModel;
8
use Resta\Support\Utils;
9
10
class Client extends ConsoleOutputter 
11
{
12
    use ConsoleListAccessor;
13
14
    /**
15
     * @var string
16
     */
17
    public $type = 'client';
18
19
    /**
20
     * @var array
21
     */
22
    protected $runnableMethods = [
23
        'create'=>'Creates request object'
24
    ];
25
26
    /**
27
     * @var bool
28
     */
29
    protected $projectStatus = true;
30
31
    /**
32
     * @var array
33
     */
34
    public $commandRule=['name','client'];
35
36
    /**
37
     * @method create
38
     * @return mixed
39
     */
40
    public function create()
41
    {
42
        $name = $this->argument['name'];
43
        $client = $this->argument['client'];
44
45
46
        $this->directory['clientNameCreate']        = path()->request();
47
        $this->argument['clientNameNamespace']      = Utils::getNamespace($this->directory['clientNameCreate']);
48
        $this->directory['clientNameDir']           = $this->directory['clientNameCreate'].'/'.$name;
49
        $this->directory['clientSource']            = $this->directory['clientNameDir'].'/'.$client;
50
        $this->argument['clientSourceNamespace']   = Utils::getNamespace($this->directory['clientNameDir'].'/'.$client.'');
51
52
        //set project directory
53
        $this->file->makeDirectory($this);
54
55
        if(!file_exists($this->directory['clientNameCreate'].'/Client.php')){
56
            $this->touch['client/client'] = $this->directory['clientNameCreate'].'/Client.php';
57
            $this->touch['client/clientGenerator'] = $this->directory['clientNameCreate'].'/ClientGenerator.php';
58
        }
59
60
        if(!file_exists($clientSourceName = $this->directory['clientSource'].'/'.$client.'.php')){
61
            $this->touch['client/source'] = $clientSourceName.'';
62
            //$this->touch['client/sourcegenerator'] = $this->directory['clientSource'].'/'.$client.'Generator.php';
63
        }
64
65
        if(!file_exists($this->directory['clientNameCreate'].'/ClientProvider.php')){
66
            $this->touch['client/clientProvider'] = $this->directory['clientNameCreate'].'/ClientProvider.php';
67
        }
68
69
        $this->touch['client/clientGeneratorFile'] = $this->directory['clientSource'].'/'.$client.'Generator.php';
70
        
71
        
72
        //set project touch
73
        $this->file->touch($this);
74
        
75
        exit();
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
76
        echo $this->classical(' > Request called as "'.$request.'" has been successfully created in the '.app()->namespace()->optionalSource().'');
0 ignored issues
show
Unused Code introduced by
echo $this->classical(' ...>optionalSource() . '') is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
77
    }
78
}