Skip to content

Commit ade22d7

Browse files
authored
Merge pull request #44 from larapack/laravel6-updates
Support for Laravel 6.0
2 parents f396962 + 9c31053 commit ade22d7

10 files changed

+26
-21
lines changed

src/Commands/DisableCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function handle()
3131

3232
$this->hooks->disable($name);
3333

34-
$this->info("Hook [{$name}] have been disabled.");
34+
$this->info("Hook [{$name}] has been disabled.");
3535
}
3636
}

src/Commands/EnableCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public function handle()
3131

3232
$this->hooks->enable($name);
3333

34-
$this->info("Hook [{$name}] have been enabled.");
34+
$this->info("Hook [{$name}] has been enabled.");
3535
}
3636
}

src/Commands/InstallCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function handle()
4040
if ($this->option('enable')) {
4141
$this->hooks->enable($name);
4242

43-
$this->info("Hook [{$name}] have been installed and enabled.");
43+
$this->info("Hook [{$name}] has been installed and enabled.");
4444
} else {
45-
$this->info("Hook [{$name}] have been installed.");
45+
$this->info("Hook [{$name}] has been installed.");
4646
}
4747
}
4848
}

src/Commands/MakeCommand.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Larapack\Hooks\Commands;
44

55
use Illuminate\Console\Command;
6+
use Illuminate\Support\Str;
67
use Larapack\Hooks\Hooks;
78

89
class MakeCommand extends Command
@@ -28,10 +29,10 @@ public function fire()
2829
public function handle()
2930
{
3031
$name = $this->argument('name');
31-
$name = kebab_case($name);
32+
$name = Str::kebab($name);
3233

3334
$this->hooks->make($name);
3435

35-
$this->info("Hook [{$name}] have been made.");
36+
$this->info("Hook [{$name}] has been made.");
3637
}
3738
}

src/Commands/SetupCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Filesystem\Filesystem;
7+
use Illuminate\Support\Str;
78
use Larapack\Hooks\Composer;
89
use Larapack\Hooks\Events\Setup;
910
use Larapack\Hooks\HooksServiceProvider;
@@ -39,7 +40,7 @@ public function handle()
3940
'url' => $this->option('url'),
4041
]);
4142

42-
if (starts_with($this->option('url'), 'http://')) {
43+
if (Str::startsWith($this->option('url'), 'http://')) {
4344
$composer->addConfig('secure-http', false);
4445
}
4546

src/Commands/UninstallCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ public function handle()
3737
!$this->option('no-unpublish')
3838
);
3939

40-
$this->info("Hook [{$name}] have been uninstalled.");
40+
$this->info("Hook [{$name}] has been uninstalled.");
4141
}
4242
}

src/Commands/UpdateCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function handle()
4545
);
4646

4747
return $updated
48-
? $this->info("Hook [{$name}] have been updated!")
48+
? $this->info("Hook [{$name}] has been updated!")
4949
: $this->info('Nothing to update.');
5050
}
5151
}

src/Hook.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use ArrayAccess;
66
use Illuminate\Contracts\Support\Arrayable;
77
use Illuminate\Filesystem\Filesystem;
8+
use Illuminate\Support\Str;
89

910
class Hook implements ArrayAccess, Arrayable
1011
{
@@ -128,7 +129,7 @@ public function mergeWithJson($path)
128129

129130
public function setAttribute($key, $value)
130131
{
131-
$method = camel_case('set_'.$key.'_attribute');
132+
$method = Str::camel('set_'.$key.'_attribute');
132133

133134
if (method_exists($this, $method)) {
134135
return $this->$method($value);
@@ -139,7 +140,7 @@ public function setAttribute($key, $value)
139140

140141
public function getAttribute($key)
141142
{
142-
$method = camel_case('get_'.$key.'_attribute');
143+
$method = Str::camel('get_'.$key.'_attribute');
143144

144145
if (method_exists($this, $method)) {
145146
return $this->$method();

src/Hooks.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use Carbon\Carbon;
66
use Illuminate\Filesystem\Filesystem;
77
use Illuminate\Foundation\Application;
8+
use Illuminate\Support\Arr;
9+
use Illuminate\Support\Str;
810
use Symfony\Component\Console\Input\ArrayInput;
911

1012
class Hooks
@@ -478,7 +480,7 @@ public function disable($name)
478480
*/
479481
public function make($name)
480482
{
481-
$studlyCase = studly_case($name);
483+
$studlyCase = Str::studly($name);
482484

483485
// Check if already exists
484486
if ($this->downloaded($name)) {
@@ -506,9 +508,9 @@ protected function makeStubFiles($name)
506508
{
507509
$replaces = [
508510
'kebab-case' => $name,
509-
'snake_case' => snake_case(str_replace('-', '_', $name)),
510-
'camelCase' => camel_case(str_replace('-', '_', $name)),
511-
'StudlyCase' => studly_case(str_replace('-', '_', $name)),
511+
'snake_case' => Str::snake(str_replace('-', '_', $name)),
512+
'camelCase' => Str::camel(str_replace('-', '_', $name)),
513+
'StudlyCase' => Str::studly(str_replace('-', '_', $name)),
512514
'MIGRATION_DATE_TIME' => $this->migrationDateTimeString(),
513515
];
514516

@@ -803,8 +805,8 @@ public function readComposerHooks($file = null)
803805
$composer = json_decode($this->filesystem->get($file), true);
804806
}
805807

806-
foreach (array_get($composer, 'packages', []) as $package) {
807-
if (array_get($package, 'notification-url') == static::$remote.'/downloads') {
808+
foreach (Arr::get($composer, 'packages', []) as $package) {
809+
if (Arr::get($package, 'notification-url') == static::$remote.'/downloads') {
808810
$hooks[$package['name']] = new Hook($package);
809811
}
810812
}
@@ -815,7 +817,7 @@ public function readComposerHooks($file = null)
815817
public function readLocalHooks()
816818
{
817819
$hooks = [];
818-
$directories = array_except($this->filesystem->directories(base_path('hooks')), ['.', '..']);
820+
$directories = Arr::except($this->filesystem->directories(base_path('hooks')), ['.', '..']);
819821
foreach ($directories as $directory) {
820822
if (!$this->filesystem->exists($directory.'/composer.json')) {
821823
continue;
@@ -879,8 +881,8 @@ public function checkForUpdates()
879881
$hooks = [];
880882
$results = json_decode($output, true);
881883

882-
foreach (array_get($results, 'installed', []) as $package) {
883-
if (isset($this->hooks[array_get($package, 'name')])) {
884+
foreach (Arr::get($results, 'installed', []) as $package) {
885+
if (isset($this->hooks[Arr::get($package, 'name')])) {
884886
$outdated[$package['name']] = $package['latest'];
885887
$hook = $this->hooks[$package['name']];
886888
$hook->setLatest($package['latest']);

src/Migrator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function rollbackMigrationsByFiles(array $migrations, $files, array $o
8888

8989
$this->runDown(
9090
$file, $migration,
91-
array_get($options, 'pretend', false)
91+
Arr::get($options, 'pretend', false)
9292
);
9393
}
9494

0 commit comments

Comments
 (0)