Skip to content

Commit

Permalink
Merge pull request #44 from larapack/laravel6-updates
Browse files Browse the repository at this point in the history
Support for Laravel 6.0
  • Loading branch information
emptynick authored Sep 5, 2019
2 parents f396962 + 9c31053 commit ade22d7
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/Commands/DisableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function handle()

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

$this->info("Hook [{$name}] have been disabled.");
$this->info("Hook [{$name}] has been disabled.");
}
}
2 changes: 1 addition & 1 deletion src/Commands/EnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public function handle()

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

$this->info("Hook [{$name}] have been enabled.");
$this->info("Hook [{$name}] has been enabled.");
}
}
4 changes: 2 additions & 2 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function handle()
if ($this->option('enable')) {
$this->hooks->enable($name);

$this->info("Hook [{$name}] have been installed and enabled.");
$this->info("Hook [{$name}] has been installed and enabled.");
} else {
$this->info("Hook [{$name}] have been installed.");
$this->info("Hook [{$name}] has been installed.");
}
}
}
5 changes: 3 additions & 2 deletions src/Commands/MakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Larapack\Hooks\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Str;
use Larapack\Hooks\Hooks;

class MakeCommand extends Command
Expand All @@ -28,10 +29,10 @@ public function fire()
public function handle()
{
$name = $this->argument('name');
$name = kebab_case($name);
$name = Str::kebab($name);

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

$this->info("Hook [{$name}] have been made.");
$this->info("Hook [{$name}] has been made.");
}
}
3 changes: 2 additions & 1 deletion src/Commands/SetupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;
use Larapack\Hooks\Composer;
use Larapack\Hooks\Events\Setup;
use Larapack\Hooks\HooksServiceProvider;
Expand Down Expand Up @@ -39,7 +40,7 @@ public function handle()
'url' => $this->option('url'),
]);

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

Expand Down
2 changes: 1 addition & 1 deletion src/Commands/UninstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public function handle()
!$this->option('no-unpublish')
);

$this->info("Hook [{$name}] have been uninstalled.");
$this->info("Hook [{$name}] has been uninstalled.");
}
}
2 changes: 1 addition & 1 deletion src/Commands/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function handle()
);

return $updated
? $this->info("Hook [{$name}] have been updated!")
? $this->info("Hook [{$name}] has been updated!")
: $this->info('Nothing to update.');
}
}
5 changes: 3 additions & 2 deletions src/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use ArrayAccess;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Str;

class Hook implements ArrayAccess, Arrayable
{
Expand Down Expand Up @@ -128,7 +129,7 @@ public function mergeWithJson($path)

public function setAttribute($key, $value)
{
$method = camel_case('set_'.$key.'_attribute');
$method = Str::camel('set_'.$key.'_attribute');

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

public function getAttribute($key)
{
$method = camel_case('get_'.$key.'_attribute');
$method = Str::camel('get_'.$key.'_attribute');

if (method_exists($this, $method)) {
return $this->$method();
Expand Down
20 changes: 11 additions & 9 deletions src/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Carbon\Carbon;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Application;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Symfony\Component\Console\Input\ArrayInput;

class Hooks
Expand Down Expand Up @@ -478,7 +480,7 @@ public function disable($name)
*/
public function make($name)
{
$studlyCase = studly_case($name);
$studlyCase = Str::studly($name);

// Check if already exists
if ($this->downloaded($name)) {
Expand Down Expand Up @@ -506,9 +508,9 @@ protected function makeStubFiles($name)
{
$replaces = [
'kebab-case' => $name,
'snake_case' => snake_case(str_replace('-', '_', $name)),
'camelCase' => camel_case(str_replace('-', '_', $name)),
'StudlyCase' => studly_case(str_replace('-', '_', $name)),
'snake_case' => Str::snake(str_replace('-', '_', $name)),
'camelCase' => Str::camel(str_replace('-', '_', $name)),
'StudlyCase' => Str::studly(str_replace('-', '_', $name)),
'MIGRATION_DATE_TIME' => $this->migrationDateTimeString(),
];

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

foreach (array_get($composer, 'packages', []) as $package) {
if (array_get($package, 'notification-url') == static::$remote.'/downloads') {
foreach (Arr::get($composer, 'packages', []) as $package) {
if (Arr::get($package, 'notification-url') == static::$remote.'/downloads') {
$hooks[$package['name']] = new Hook($package);
}
}
Expand All @@ -815,7 +817,7 @@ public function readComposerHooks($file = null)
public function readLocalHooks()
{
$hooks = [];
$directories = array_except($this->filesystem->directories(base_path('hooks')), ['.', '..']);
$directories = Arr::except($this->filesystem->directories(base_path('hooks')), ['.', '..']);
foreach ($directories as $directory) {
if (!$this->filesystem->exists($directory.'/composer.json')) {
continue;
Expand Down Expand Up @@ -879,8 +881,8 @@ public function checkForUpdates()
$hooks = [];
$results = json_decode($output, true);

foreach (array_get($results, 'installed', []) as $package) {
if (isset($this->hooks[array_get($package, 'name')])) {
foreach (Arr::get($results, 'installed', []) as $package) {
if (isset($this->hooks[Arr::get($package, 'name')])) {
$outdated[$package['name']] = $package['latest'];
$hook = $this->hooks[$package['name']];
$hook->setLatest($package['latest']);
Expand Down
2 changes: 1 addition & 1 deletion src/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function rollbackMigrationsByFiles(array $migrations, $files, array $o

$this->runDown(
$file, $migration,
array_get($options, 'pretend', false)
Arr::get($options, 'pretend', false)
);
}

Expand Down

0 comments on commit ade22d7

Please sign in to comment.