Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions init/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,6 @@ function camel_case($value)
}
}

if (!function_exists('ends_with')) {
/**
* ends_with determines if a given string ends with a given substring
* @param string $haystack
* @param string|array $needles
* @return bool
*/
function ends_with($haystack, $needles)
{
return Str::endsWith($haystack, $needles);
}
}

if (!function_exists('kebab_case')) {
/**
* kebab_case converts a string to kebab case
Expand All @@ -601,19 +588,6 @@ function snake_case($value, $delimiter = '_')
}
}

if (!function_exists('starts_with')) {
/**
* starts_with determines if a given string starts with a given substring
* @param string $haystack
* @param string|array $needles
* @return bool
*/
function starts_with($haystack, $needles)
{
return Str::startsWith($haystack, $needles);
}
}

if (!function_exists('str_after')) {
/**
* str_after returns the remainder of a string after a given value
Expand Down
12 changes: 6 additions & 6 deletions src/Auth/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function hasAccess($permissions, $all = true)
// Now, let's check if the permission ends in a wildcard "*" symbol.
// If it does, we'll check through all the merged permissions to see
// if a permission exists which matches the wildcard.
if ((strlen($permission) > 1) && ends_with($permission, '*')) {
if ((strlen($permission) > 1) && str_ends_with($permission, '*')) {
$matched = false;

foreach ($rolePermissions as $rolePermission => $value) {
Expand All @@ -88,7 +88,7 @@ public function hasAccess($permissions, $all = true)
// exactly match our permission, but starts with it.
if (
$checkPermission !== $rolePermission &&
starts_with($rolePermission, $checkPermission) &&
str_starts_with($rolePermission, $checkPermission) &&
(int) $value === 1
) {
$matched = true;
Expand All @@ -99,7 +99,7 @@ public function hasAccess($permissions, $all = true)
// Now, let's check if the permission starts in a wildcard "*" symbol.
// If it does, we'll check through all the merged permissions to see
// if a permission exists which matches the wildcard.
elseif ((strlen($permission) > 1) && starts_with($permission, '*')) {
elseif ((strlen($permission) > 1) && str_starts_with($permission, '*')) {
$matched = false;

foreach ($rolePermissions as $rolePermission => $value) {
Expand All @@ -110,7 +110,7 @@ public function hasAccess($permissions, $all = true)
// exactly match our permission, but ends with it.
if (
$checkPermission !== $rolePermission &&
ends_with($rolePermission, $checkPermission) &&
str_ends_with($rolePermission, $checkPermission) &&
(int) $value === 1
) {
$matched = true;
Expand All @@ -123,7 +123,7 @@ public function hasAccess($permissions, $all = true)

foreach ($rolePermissions as $rolePermission => $value) {
// This time check if the rolePermission ends in wildcard "*" symbol.
if ((strlen($rolePermission) > 1) && ends_with($rolePermission, '*')) {
if ((strlen($rolePermission) > 1) && str_ends_with($rolePermission, '*')) {
$matched = false;

// Strip the '*' off the end of the permission.
Expand All @@ -133,7 +133,7 @@ public function hasAccess($permissions, $all = true)
// exactly match our permission, but starts with it.
if (
$checkGroupPermission !== $permission &&
starts_with($permission, $checkGroupPermission) &&
str_starts_with($permission, $checkGroupPermission) &&
(int) $value === 1
) {
$matched = true;
Expand Down
12 changes: 6 additions & 6 deletions src/Auth/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public function hasPermission($permissions, $all = true)
// Now, let's check if the permission ends in a wildcard "*" symbol.
// If it does, we'll check through all the merged permissions to see
// if a permission exists which matches the wildcard.
if ((strlen($permission) > 1) && ends_with($permission, '*')) {
if ((strlen($permission) > 1) && str_ends_with($permission, '*')) {
$matched = false;

foreach ($mergedPermissions as $mergedPermission => $value) {
Expand All @@ -553,15 +553,15 @@ public function hasPermission($permissions, $all = true)
// exactly match our permission, but starts with it.
if (
$checkPermission !== $mergedPermission &&
starts_with($mergedPermission, $checkPermission) &&
str_starts_with($mergedPermission, $checkPermission) &&
(int) $value === 1
) {
$matched = true;
break;
}
}
}
elseif ((strlen($permission) > 1) && starts_with($permission, '*')) {
elseif ((strlen($permission) > 1) && str_starts_with($permission, '*')) {
$matched = false;

foreach ($mergedPermissions as $mergedPermission => $value) {
Expand All @@ -572,7 +572,7 @@ public function hasPermission($permissions, $all = true)
// exactly match our permission, but ends with it.
if (
$checkPermission !== $mergedPermission &&
ends_with($mergedPermission, $checkPermission) &&
str_ends_with($mergedPermission, $checkPermission) &&
(int) $value === 1
) {
$matched = true;
Expand All @@ -585,7 +585,7 @@ public function hasPermission($permissions, $all = true)

foreach ($mergedPermissions as $mergedPermission => $value) {
// This time check if the mergedPermission ends in wildcard "*" symbol.
if ((strlen($mergedPermission) > 1) && ends_with($mergedPermission, '*')) {
if ((strlen($mergedPermission) > 1) && str_ends_with($mergedPermission, '*')) {
$matched = false;

// Strip the '*' off the end of the permission.
Expand All @@ -595,7 +595,7 @@ public function hasPermission($permissions, $all = true)
// exactly match our permission, but starts with it.
if (
$checkMergedPermission !== $permission &&
starts_with($permission, $checkMergedPermission) &&
str_starts_with($permission, $checkMergedPermission) &&
(int) $value === 1
) {
$matched = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Attach/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ public function deleteThumbs()
$allFiles = $this->storageCmd('files', $directory);
$collection = [];
foreach ($allFiles as $file) {
if (starts_with(basename($file), $pattern)) {
if (str_starts_with(basename($file), $pattern)) {
$collection[] = $file;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Foundation/Providers/ExecutionContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function determineContext($app): string

$backendUri = $this->normalizeUrl($app['config']->get('backend.uri', 'backend'));

if (starts_with($requestPath, $backendUri)) {
if (str_starts_with($requestPath, $backendUri)) {
return 'backend';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Halcyon/Traits/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ protected function processValidationRules($rules)
// Analyse each rule individually
foreach ($ruleParts as $key => $rulePart) {
// Look for required:create and required:update rules
if (starts_with($rulePart, 'required:create') && $this->exists) {
if (str_starts_with($rulePart, 'required:create') && $this->exists) {
unset($ruleParts[$key]);
}
elseif (starts_with($rulePart, 'required:update') && !$this->exists) {
elseif (str_starts_with($rulePart, 'required:update') && !$this->exists) {
unset($ruleParts[$key]);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Html/HtmlBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Html;

use October\Rain\Support\Str;
use Illuminate\Routing\UrlGenerator;

/**
Expand Down Expand Up @@ -585,7 +586,7 @@ public static function cleanVector(string $html): string
*/
public function isValidColor(string $value): bool
{
return starts_with($value, [
return Str::startsWith($value, [
'#',
'var(',
'rgb(',
Expand Down
3 changes: 2 additions & 1 deletion src/Parse/Syntax/SyntaxModelTrait.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace October\Rain\Parse\Syntax;

use October\Rain\Support\Str;
use Request;

/**
Expand Down Expand Up @@ -102,7 +103,7 @@ protected function getThumbForImage($image, $params = [])
$path = $image->getPath();
}

if (!starts_with($path, ['//', 'http://', 'https://'])) {
if (!Str::startsWith($path, ['//', 'http://', 'https://'])) {
$path = Request::getSchemeAndHttpHost() . $path;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Scaffold/Console/CreateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CreateFactory extends GeneratorCommandBase
*/
public function handle()
{
if (!ends_with($this->argument('name'), 'Factory')) {
if (!str_ends_with($this->argument('name'), 'Factory')) {
$this->components->error('Factory classes names must end in "Factory"');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Scaffold/Console/CreateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class CreateTest extends GeneratorCommandBase
*/
public function handle()
{
if (!ends_with($this->argument('name'), 'Test')) {
if (!str_ends_with($this->argument('name'), 'Test')) {
$this->components->error('Test classes names must end in "Test"');
return;
}
Expand Down