1
|
|
|
<?php
|
2
|
|
|
|
3
|
|
|
namespace Arrilot\LaravelDataAnonymization\Commands;
|
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Composer;
|
6
|
|
|
use Illuminate\Filesystem\Filesystem;
|
7
|
|
|
use Illuminate\Console\GeneratorCommand;
|
8
|
|
|
|
9
|
|
|
class MakeAnonymizerCommand extends GeneratorCommand
|
10
|
|
|
{
|
11
|
|
|
/**
|
12
|
|
|
* The console command name.
|
13
|
|
|
*
|
14
|
|
|
* @var string
|
15
|
|
|
*/
|
16
|
|
|
protected $name = 'make:anonymizer';
|
17
|
|
|
|
18
|
|
|
/**
|
19
|
|
|
* The console command description.
|
20
|
|
|
*
|
21
|
|
|
* @var string
|
22
|
|
|
*/
|
23
|
|
|
protected $description = 'Create a new anonymizer class';
|
24
|
|
|
|
25
|
|
|
/**
|
26
|
|
|
* The type of class being generated.
|
27
|
|
|
*
|
28
|
|
|
* @var string
|
29
|
|
|
*/
|
30
|
|
|
protected $type = 'Anonymizer';
|
31
|
|
|
|
32
|
|
|
/**
|
33
|
|
|
* The Composer instance.
|
34
|
|
|
*
|
35
|
|
|
* @var \Illuminate\Support\Composer
|
36
|
|
|
*/
|
37
|
|
|
protected $composer;
|
38
|
|
|
|
39
|
|
|
/**
|
40
|
|
|
* Create a new command instance.
|
41
|
|
|
*
|
42
|
|
|
* @param \Illuminate\Filesystem\Filesystem $files
|
43
|
|
|
* @param \Illuminate\Support\Composer $composer
|
44
|
|
|
*/
|
45
|
|
|
public function __construct(Filesystem $files, Composer $composer)
|
46
|
|
|
{
|
47
|
|
|
parent::__construct($files);
|
48
|
|
|
|
49
|
|
|
$this->composer = $composer;
|
50
|
|
|
}
|
51
|
|
|
|
52
|
|
|
public function handle()
|
53
|
|
|
{
|
54
|
|
|
return $this->fire();
|
55
|
|
|
}
|
56
|
|
|
|
57
|
|
|
/**
|
58
|
|
|
* Execute the console command.
|
59
|
|
|
*
|
60
|
|
|
* @return void
|
61
|
|
|
*/
|
62
|
|
|
public function fire()
|
63
|
|
|
{
|
64
|
|
|
parent::fire();
|
65
|
|
|
|
66
|
|
|
$this->composer->dumpAutoloads();
|
67
|
|
|
}
|
68
|
|
|
|
69
|
|
|
/**
|
70
|
|
|
* Get the stub file for the generator.
|
71
|
|
|
*
|
72
|
|
|
* @return string
|
73
|
|
|
*/
|
74
|
|
|
protected function getStub()
|
75
|
|
|
{
|
76
|
|
|
return __DIR__.'/stubs/anonymizer.stub';
|
77
|
|
|
}
|
78
|
|
|
|
79
|
|
|
/**
|
80
|
|
|
* Get the destination class path.
|
81
|
|
|
*
|
82
|
|
|
* @param string $name
|
83
|
|
|
* @return string
|
84
|
|
|
*/
|
85
|
|
|
protected function getPath($name)
|
86
|
|
|
{
|
87
|
|
|
return $this->laravel->databasePath().'/anonymization/'.$name.'.php';
|
|
|
|
|
88
|
|
|
}
|
89
|
|
|
|
90
|
|
|
/**
|
91
|
|
|
* Parse the name and format according to the root namespace.
|
92
|
|
|
*
|
93
|
|
|
* @param string $name
|
94
|
|
|
* @return string
|
95
|
|
|
*/
|
96
|
|
|
protected function parseName($name)
|
97
|
|
|
{
|
98
|
|
|
return $name;
|
99
|
|
|
}
|
100
|
|
|
}
|
101
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.