Skip to content

Commit 87830d3

Browse files
committed
Merge branch 'feature/exploration' into master8.3
2 parents ad228b9 + 3515569 commit 87830d3

File tree

4 files changed

+303
-0
lines changed

4 files changed

+303
-0
lines changed

composer.lock

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Commands/CommandMakeCommand.php

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?php
2+
3+
/**
4+
* PHP version 8
5+
*
6+
* @category Library
7+
* @package Commands
8+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
9+
* @license https://mit-license.org/ MIT License
10+
* @version GIT: 0.0.6
11+
* @link https://github.com/spotlibs
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace Spotlibs\PhpLib\Commands;
17+
18+
use Illuminate\Console\GeneratorCommand;
19+
use Symfony\Component\Console\Input\InputOption;
20+
21+
/**
22+
* ControllerMakeCommand
23+
*
24+
* Standard command
25+
*
26+
* @category Console
27+
* @package Commands
28+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
29+
* @license https://mit-license.org/ MIT License
30+
* @link https://github.com/spotlibs
31+
*/
32+
class CommandMakeCommand extends GeneratorCommand
33+
{
34+
/**
35+
* The console command name.
36+
*
37+
* @var string
38+
*/
39+
protected $name = 'make:command';
40+
/**
41+
* The console command description.
42+
*
43+
* @var string
44+
*/
45+
protected $description = 'Create a new command class';
46+
/**
47+
* The type of class being generated.
48+
*
49+
* @var string
50+
*/
51+
protected $type = 'Command';
52+
/**
53+
* Execute the console command.
54+
*
55+
* @return void
56+
*/
57+
public function handle()
58+
{
59+
parent::handle();
60+
}
61+
/**
62+
* Get the destination class path.
63+
*
64+
* @param string $name name of the type
65+
*
66+
* @return string
67+
*/
68+
protected function getPath($name)
69+
{
70+
return parent::getPath($name . 'Command');
71+
}
72+
/**
73+
* ReplaceClass
74+
*
75+
* @param string $stub filename of stub file
76+
* @param string $name name of the type
77+
*
78+
* @return string|string[]
79+
*/
80+
protected function replaceClass($stub, $name)
81+
{
82+
$stub = parent::replaceClass($stub, $name);
83+
$temp = explode("/", $this->argument('name'));
84+
$signature = 'signature:' . strtolower($temp[count($temp) - 1]);
85+
$stub = str_replace('DummySignature', $signature, $stub);
86+
return $stub;
87+
}
88+
/**
89+
* Get the stub file for the generator.
90+
*
91+
* @return string
92+
*/
93+
protected function getStub()
94+
{
95+
if ($this->option('resource')) {
96+
return __DIR__ . '/stubs/command.stub';
97+
}
98+
return __DIR__ . '/stubs/command.plain.stub';
99+
}
100+
/**
101+
* Get the default namespace for the class.
102+
*
103+
* @param string $rootNamespace namespace of root (generally App)
104+
*
105+
* @return string
106+
*/
107+
protected function getDefaultNamespace($rootNamespace)
108+
{
109+
return $rootNamespace . '\Console\Commands';
110+
}
111+
/**
112+
* Get the console command options.
113+
*
114+
* @return array
115+
*/
116+
protected function getOptions()
117+
{
118+
return [
119+
['resource', null, InputOption::VALUE_NONE, 'Generate a resource command class.'],
120+
];
121+
}
122+
}

src/Commands/stubs/command.plain.stub

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/**
4+
* PHP version 8.0.30
5+
*
6+
* @category Application
7+
* @package Commands
8+
* @author
9+
* @license https://mit-license.org/ MIT License
10+
* @version GIT: 0.0.1
11+
* @link https://github.com/
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace DummyNamespace;
17+
18+
use Spotlibs\PhpLib\Commands\Command;
19+
use Spotlibs\PhpLib\Logs\Log;
20+
21+
/**
22+
* DummyClassCommand
23+
*
24+
* Doing some tasks through CLI input
25+
*
26+
* @category Commands
27+
* @package Commands
28+
* @author
29+
* @license https://mit-license.org/ MIT License
30+
* @link https://github.com/
31+
*/
32+
class DummyClassCommand extends Command
33+
{
34+
// phpcs:ignore
35+
protected $signature = 'DummySignature';
36+
// phpcs:ignore
37+
protected $description = 'brief description of what this command for...';
38+
39+
public function __construct()
40+
{
41+
parent::__construct();
42+
}
43+
44+
public function handle(): void
45+
{
46+
/**
47+
* Adding traceID and identifier for logger context.
48+
* Deleting this may cause the logger can not log the traceID and identifier.
49+
* Consider to keep this line below.
50+
*/
51+
parent::setContext(); //adding traceID and identifier for logger context
52+
53+
Log::worker()->info(['message' => 'DummyClass process begin']);
54+
}
55+
}

src/Libraries/MapRoute.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* PHP version 8
5+
*
6+
* @category Library
7+
* @package Libraries
8+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
9+
* @license https://mit-license.org/ MIT License
10+
* @version GIT: 0.3.7
11+
* @link https://github.com/spotlibs
12+
*/
13+
14+
declare(strict_types=1);
15+
16+
namespace Spotlibs\PhpLib\Libraries;
17+
18+
/**
19+
* MapRoute
20+
*
21+
* Name for HTTP Client timeout unit
22+
*
23+
* @category HttpClient
24+
* @package Client
25+
* @author Made Mas Adi Winata <m45adiwinata@gmail.com>
26+
* @license https://mit-license.org/ MIT License
27+
* @link https://github.com/spotlibs
28+
*/
29+
class MapRoute
30+
{
31+
public int $id;
32+
public string $target_url;
33+
public string $mock_url;
34+
public bool $flag;
35+
36+
/**
37+
* Create MapRoute instance
38+
*
39+
* @param array $data maproute data
40+
*/
41+
public function __construct(array $data)
42+
{
43+
$this->id = $data['id'];
44+
$this->target_url = $data['target_url'];
45+
$this->mock_url = $data['mock_url'];
46+
$this->flag = $data['flag'];
47+
}
48+
}

0 commit comments

Comments
 (0)