1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace KMLaravel\ApiGenerator\Helpers; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Illuminate\Support\Facades\File; |
|
|
|
|
8
|
|
|
|
9
|
|
|
class KMFile |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @param $fileName |
13
|
|
|
* @return string |
14
|
|
|
*/ |
15
|
|
|
public static function getFilesFromStubs($fileName) |
16
|
|
|
{ |
17
|
|
|
return __DIR__ . "/../Stubs/$fileName.stub"; |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param $fileName |
22
|
|
|
* @return string |
23
|
|
|
*/ |
24
|
|
|
public static function getFilesFromStubsAsStream($fileName) |
25
|
|
|
{ |
26
|
|
|
return File::get(__DIR__ . "/../Stubs/$fileName.stub"); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param $fileName |
31
|
|
|
* @return string |
32
|
|
|
*/ |
33
|
|
|
public static function getRequestFile($fileName) |
34
|
|
|
{ |
35
|
|
|
return app_path("Http/Requests/$fileName"); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $fileName |
40
|
|
|
* @return string |
41
|
|
|
*/ |
42
|
|
|
public static function getResourceFile($fileName) |
43
|
|
|
{ |
44
|
|
|
return app_path("Http/Resources/$fileName"); |
|
|
|
|
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param $fileName |
49
|
|
|
* @return string |
50
|
|
|
*/ |
51
|
|
|
public static function getModelFile($fileName) |
52
|
|
|
{ |
53
|
|
|
return app_path("$fileName"); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param $fileName |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public static function getRequestFileAsStream($fileName) |
61
|
|
|
{ |
62
|
|
|
return File::get(app_path("Http/Requests/$fileName")); |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $fileName |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public static function getModelFileAsStream($fileName) |
70
|
|
|
{ |
71
|
|
|
return File::get(app_path($fileName)); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param $type |
76
|
|
|
* @param $className |
77
|
|
|
* @return string |
78
|
|
|
*/ |
79
|
|
|
public static function getClassNameSpace($type, $className) |
80
|
|
|
{ |
81
|
|
|
if ($type == "model") { |
82
|
|
|
return "App\\$className"; |
83
|
|
|
} |
84
|
|
|
return "App\\Http\\$type\\$className"; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public static function getCredentialJsonFilePath() |
91
|
|
|
{ |
92
|
|
|
if (File::exists(resource_path("Views/ApisGenerator/credential.json"))) { |
|
|
|
|
93
|
|
|
return resource_path("Views/ApisGenerator/credential.json"); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return mixed |
99
|
|
|
*/ |
100
|
|
|
public static function getCredentialJsonFileAsJson() |
101
|
|
|
{ |
102
|
|
|
if (File::exists(resource_path("Views/ApisGenerator/credential.json"))) { |
|
|
|
|
103
|
|
|
return json_decode(File::get(self::getCredentialJsonFilePath())); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param $newData |
109
|
|
|
*/ |
110
|
|
|
public static function setDataToCredentialJsonFile($newData) |
111
|
|
|
{ |
112
|
|
|
$data = self::getCredentialJsonFileAsJson(); |
113
|
|
|
|
114
|
|
|
array_push($data, $newData); |
|
|
|
|
115
|
|
|
|
116
|
|
|
File::put(self::getCredentialJsonFilePath(), json_encode($data)); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @return bool |
121
|
|
|
*/ |
122
|
|
|
public static function baseControllerExists() |
123
|
|
|
{ |
124
|
|
|
return File::exists(static::baseControllerPath()); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return string |
129
|
|
|
*/ |
130
|
|
|
public static function baseControllerPath() |
131
|
|
|
{ |
132
|
|
|
return app_path("Http/Controllers/BaseController.php"); |
|
|
|
|
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths