Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #1

Merged
merged 1 commit into from
Sep 1, 2018
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
9 changes: 4 additions & 5 deletions src/Rules/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Domain
* @package MDooley47\UrlValidator\Rules
* Class Domain.
*/
class Domain
{
Expand All @@ -24,8 +23,8 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'domain');

return (Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[1])
== Str::lower($parameters[0]));
return Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[1])
== Str::lower($parameters[0]);
}

/**
Expand All @@ -37,4 +36,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Fragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Fragment
* @package MDooley47\UrlValidator\Rules
* Class Fragment.
*/
class Fragment
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'fragment');

return (Str::lower(parse_url($value, PHP_URL_FRAGMENT)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_FRAGMENT)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Host
* @package MDooley47\UrlValidator\Rules
* Class Host.
*/
class Host
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'host');

return (Str::lower(parse_url($value, PHP_URL_HOST)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_HOST)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Pass
* @package MDooley47\UrlValidator\Rules
* Class Pass.
*/
class Pass
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'pass');

return (Str::lower(parse_url($value, PHP_URL_PASS)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_PASS)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Port
* @package MDooley47\UrlValidator\Rules
* Class Port.
*/
class Path
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'path');

return (Str::lower(parse_url($value, PHP_URL_PATH)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_PATH)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Port
* @package MDooley47\UrlValidator\Rules
* Class Port.
*/
class Port
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'port');

return (Str::lower(parse_url($value, PHP_URL_PORT)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_PORT)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Query
* @package MDooley47\UrlValidator\Rules
* Class Query.
*/
class Query
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'query');

return (Str::lower(parse_url($value, PHP_URL_QUERY)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_QUERY)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/Scheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Scheme
* @package MDooley47\UrlValidator\Rules
* Class Scheme.
*/
class Scheme
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'scheme');

return (Str::lower(parse_url($value, PHP_URL_SCHEME)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_SCHEME)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
9 changes: 4 additions & 5 deletions src/Rules/Subdomain.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Subdomain
* @package MDooley47\UrlValidator\Rules
* Class Subdomain.
*/
class Subdomain
{
Expand All @@ -24,8 +23,8 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'subdomain');

return (Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[0])
== Str::lower($parameters[0]));
return Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[0])
== Str::lower($parameters[0]);
}

/**
Expand All @@ -37,4 +36,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
9 changes: 4 additions & 5 deletions src/Rules/Tld.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class Tld
* @package MDooley47\UrlValidator\Rules
* Class Tld.
*/
class Tld
{
Expand All @@ -24,8 +23,8 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'tld');

return (Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[2])
== Str::lower($parameters[0]));
return Str::lower(explode('.', parse_url($value, PHP_URL_HOST))[2])
== Str::lower($parameters[0]);
}

/**
Expand All @@ -37,4 +36,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
7 changes: 3 additions & 4 deletions src/Rules/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
use Illuminate\Support\Str;

/**
* Class User
* @package MDooley47\UrlValidator\Rules
* Class User.
*/
class User
{
Expand All @@ -24,7 +23,7 @@ public function passes($attribute, $value, $parameters, $validator)
{
// $validator->requireParameterCount(1, $parameters, 'user');

return (Str::lower(parse_url($value, PHP_URL_USER)) == Str::lower($parameters[0]));
return Str::lower(parse_url($value, PHP_URL_USER)) == Str::lower($parameters[0]);
}

/**
Expand All @@ -36,4 +35,4 @@ public static function message()
{
return 'The :attribute must be :value.';
}
}
}
10 changes: 5 additions & 5 deletions src/UrlValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace MDooley47\UrlValidator;

use Illuminate\Support\Str;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;

class UrlValidator
{
/**
* @param string $url
* @param array $options
* @param array $options
*
* @return bool
*/
Expand All @@ -18,7 +18,7 @@ public static function match($url, array $options)
// build the rules
$rules = '';
foreach ($options as $key => $value) {
switch(Str::lower($key)) {
switch (Str::lower($key)) {
case 'scheme':
$rules .= "|scheme:${value}";
break;
Expand Down Expand Up @@ -56,9 +56,9 @@ public static function match($url, array $options)
}

$validate = Validator::make(['url' => $url], [
'url' => 'required|url' . $rules,
'url' => 'required|url'.$rules,
]);

return $validate->passes();
}
}
}
27 changes: 13 additions & 14 deletions src/UrlValidatorServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?php

namespace MDooley47\UrlValidator;

use MDooley47\UrlValidator\Rules\Scheme;
use MDooley47\UrlValidator\Rules\User;
use MDooley47\UrlValidator\Rules\Pass;
use MDooley47\UrlValidator\Rules\Host;
use MDooley47\UrlValidator\Rules\Subdomain;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use MDooley47\UrlValidator\Rules\Domain;
use MDooley47\UrlValidator\Rules\Tld;
use MDooley47\UrlValidator\Rules\Port;
use MDooley47\UrlValidator\Rules\Fragment;
use MDooley47\UrlValidator\Rules\Host;
use MDooley47\UrlValidator\Rules\Pass;
use MDooley47\UrlValidator\Rules\Path;
use MDooley47\UrlValidator\Rules\Port;
use MDooley47\UrlValidator\Rules\Query;
use MDooley47\UrlValidator\Rules\Fragment;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use MDooley47\UrlValidator\Rules\Scheme;
use MDooley47\UrlValidator\Rules\Subdomain;
use MDooley47\UrlValidator\Rules\Tld;
use MDooley47\UrlValidator\Rules\User;

/**
* Class UrlValidatorServiceProvider
* @package MDooley47\UrlValidator
* Class UrlValidatorServiceProvider.
*/
class UrlValidatorServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -51,4 +50,4 @@ public function register()
{
//
}
}
}