Skip to content

Commit

Permalink
Use Arr and Str classes. (#20879)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot authored and taylorotwell committed Aug 31, 2017
1 parent a3cdf51 commit 38630c9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Auth\Access;

use Illuminate\Support\Str;
use Illuminate\Contracts\Auth\Access\Gate;

trait AuthorizesRequests
Expand Down Expand Up @@ -81,7 +82,7 @@ protected function normalizeGuessedAbilityName($ability)
*/
public function authorizeResource($model, $parameter = null, array $options = [], $request = null)
{
$parameter = $parameter ?: snake_case(lcfirst(class_basename($model)));
$parameter = $parameter ?: Str::snake(lcfirst(class_basename($model)));

$middleware = [];

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Foundation/Console/TestMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Foundation\Console;

use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;

class TestMakeCommand extends GeneratorCommand
Expand Down Expand Up @@ -49,7 +50,7 @@ protected function getStub()
*/
protected function getPath($name)
{
$name = str_replace_first($this->rootNamespace(), '', $name);
$name = Str::replaceFirst($this->rootNamespace(), '', $name);

return $this->laravel->basePath().'/tests'.str_replace('\\', '/', $name).'.php';
}
Expand Down
5 changes: 3 additions & 2 deletions src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Support\Str;
use Illuminate\Support\Carbon;
use Illuminate\Support\HtmlString;
use Illuminate\Container\Container;
Expand Down Expand Up @@ -546,11 +547,11 @@ function mix($path, $manifestDirectory = '')
{
static $manifests = [];

if (! starts_with($path, '/')) {
if (! Str::startsWith($path, '/')) {
$path = "/{$path}";
}

if ($manifestDirectory && ! starts_with($manifestDirectory, '/')) {
if ($manifestDirectory && ! Str::startsWith($manifestDirectory, '/')) {
$manifestDirectory = "/{$manifestDirectory}";
}

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Http/Resources/Json/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ArrayAccess;
use JsonSerializable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Container\Container;
use Illuminate\Http\Resources\MergeValue;
Expand Down Expand Up @@ -256,7 +257,7 @@ protected function mergeWhen($condition, $value)
protected function attributes($attributes)
{
return new MergeValue(
array_only($this->resource->toArray(), $attributes)
Arr::only($this->resource->toArray(), $attributes)
);
}

Expand Down

0 comments on commit 38630c9

Please sign in to comment.