Skip to content

Commit 6718f5f

Browse files
authored
style: use app methods instead of functions (#507)
1 parent 9e2c9d4 commit 6718f5f

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

src/Components/Database/Installer.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function install(): void
5353
$this->task(
5454
'Creating a default SQLite database',
5555
function () {
56-
if (File::exists(database_path('database.sqlite'))) {
56+
if (File::exists($this->app->databasePath('database.sqlite'))) {
5757
return false;
5858
}
5959

@@ -107,24 +107,27 @@ function () {
107107
$this->task(
108108
'Creating default database configuration',
109109
function () {
110-
if (File::exists(config_path('database.php'))) {
110+
if (File::exists($this->app->configPath('database.php'))) {
111111
return false;
112112
}
113113

114114
return File::copy(
115115
self::CONFIG_FILE,
116-
config_path('database.php')
116+
$this->app->configPath('database.php')
117117
);
118118
}
119119
);
120120

121121
$this->task(
122122
'Updating .gitignore',
123123
function () {
124-
$gitignorePath = base_path('.gitignore');
124+
$gitignorePath = $this->app->basePath('.gitignore');
125125
if (File::exists($gitignorePath)) {
126126
$contents = File::get($gitignorePath);
127-
$neededLine = '/database/database.sqlite';
127+
$neededLine = strtr($this->app->databasePath('database.sqlite'), [
128+
$this->app->basePath() => '',
129+
'\\' => '/',
130+
]);
128131
if (! Str::contains($contents, $neededLine)) {
129132
File::append($gitignorePath, $neededLine.PHP_EOL);
130133

src/Components/Dotenv/Installer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public function install(): void
4040
$this->task(
4141
'Creating .env',
4242
function () {
43-
if (! File::exists(base_path('.env'))) {
44-
return File::put(base_path('.env'), 'CONSUMER_KEY=');
43+
if (! File::exists($this->app->basePath('.env'))) {
44+
return File::put($this->app->basePath('.env'), 'CONSUMER_KEY=');
4545
}
4646

4747
return false;
@@ -51,8 +51,8 @@ function () {
5151
$this->task(
5252
'Creating .env.example',
5353
function () {
54-
if (! File::exists(base_path('.env.example'))) {
55-
return File::put(base_path('.env.example'), 'CONSUMER_KEY=');
54+
if (! File::exists($this->app->basePath('.env.example'))) {
55+
return File::put($this->app->basePath('.env.example'), 'CONSUMER_KEY=');
5656
}
5757

5858
return false;
@@ -62,7 +62,7 @@ function () {
6262
$this->task(
6363
'Updating .gitignore',
6464
function () {
65-
$gitignorePath = base_path('.gitignore');
65+
$gitignorePath = $this->app->basePath('.gitignore');
6666
if (File::exists($gitignorePath)) {
6767
$contents = File::get($gitignorePath);
6868
$neededLine = '.env';

src/Components/Log/Installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function install(): void
4646
$this->task(
4747
'Creating default logging configuration',
4848
function () {
49-
if (! File::exists(config_path('logging.php'))) {
49+
if (! File::exists($this->app->configPath('logging.php'))) {
5050
return File::copy(
5151
static::CONFIG_FILE,
5252
$this->app->configPath('logging.php')

src/Components/Queue/Installer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function install(): void
4949
$this->task(
5050
'Creating default queue configuration',
5151
function () {
52-
if (! File::exists(config_path('queue.php'))) {
52+
if (! File::exists($this->app->configPath('queue.php'))) {
5353
return File::copy(
5454
self::CONFIG_FILE,
5555
$this->app->configPath('queue.php')

src/Components/Updater/Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function register(): void
6767
$this->app->singleton(Updater::class, function () use ($build) {
6868
$updater = new PharUpdater($build->getPath(), false, PharUpdater::STRATEGY_GITHUB);
6969

70-
$composer = json_decode(file_get_contents(base_path('composer.json')), true);
70+
$composer = json_decode(file_get_contents($this->app->basePath('composer.json')), true);
7171
$name = $composer['name'];
7272

7373
$strategy = $this->app['config']->get('updater.strategy', GithubStrategy::class);

src/Components/View/Installer.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function install(): void
4646
$this->task(
4747
'Creating resources/views folder',
4848
function () {
49-
if (! File::exists(base_path('resources/views'))) {
50-
File::makeDirectory(base_path('resources/views'), 0755, true, true);
49+
if (! File::exists($this->app->resourcePath('views'))) {
50+
File::makeDirectory($this->app->resourcePath('views'), 0755, true, true);
5151

5252
return true;
5353
}
@@ -59,7 +59,7 @@ function () {
5959
$this->task(
6060
'Creating default view configuration',
6161
function () {
62-
if (! File::exists(config_path('view.php'))) {
62+
if (! File::exists($this->app->configPath('view.php'))) {
6363
return File::copy(
6464
static::CONFIG_FILE,
6565
$this->app->configPath('view.php')
@@ -73,26 +73,26 @@ function () {
7373
$this->task(
7474
'Creating cache storage folder',
7575
function () {
76-
if (File::exists(base_path('storage/app/.gitignore')) &&
77-
File::exists(base_path('storage/framework/views/.gitignore'))
76+
if (File::exists($this->app->storagePath('app/.gitignore')) &&
77+
File::exists($this->app->storagePath('framework/views/.gitignore'))
7878
) {
7979
return false;
8080
}
8181

82-
if (! File::exists(base_path('storage/app'))) {
83-
File::makeDirectory(base_path('storage/app'), 0755, true, true);
82+
if (! File::exists($this->app->storagePath('app'))) {
83+
File::makeDirectory($this->app->storagePath('app'), 0755, true, true);
8484
}
8585

86-
if (! File::exists(base_path('storage/app/.gitignore'))) {
87-
File::append(base_path('storage/app/.gitignore'), "*\n!.gitignore");
86+
if (! File::exists($this->app->storagePath('app/.gitignore'))) {
87+
File::append($this->app->storagePath('app/.gitignore'), "*\n!.gitignore");
8888
}
8989

90-
if (! File::exists(base_path('storage/framework/views'))) {
91-
File::makeDirectory(base_path('storage/framework/views'), 0755, true, true);
90+
if (! File::exists($this->app->storagePath('framework/views'))) {
91+
File::makeDirectory($this->app->storagePath('framework/views'), 0755, true, true);
9292
}
9393

94-
if (! File::exists(base_path('storage/framework/views/.gitignore'))) {
95-
File::append(base_path('storage/framework/views/.gitignore'), "*\n!.gitignore");
94+
if (! File::exists($this->app->storagePath('framework/views/.gitignore'))) {
95+
File::append($this->app->storagePath('framework/views/.gitignore'), "*\n!.gitignore");
9696
}
9797

9898
return true;

0 commit comments

Comments
 (0)