Skip to content

Commit

Permalink
Move DateUtils.php into Traits directory
Browse files Browse the repository at this point in the history
  • Loading branch information
emsifa committed Nov 24, 2018
1 parent cedc217 commit 9e1f8e6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Rules/After.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class After extends Rule
{

use DateUtils;
use Traits\DateUtilsTrait;

/** @var string */
protected $message = "The :attribute must be a date after :time.";
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Before.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Before extends Rule
{
use DateUtils;
use Traits\DateUtilsTrait;

/** @var string */
protected $message = "The :attribute must be a date before :time.";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Rakit\Validation\Rules;
namespace Rakit\Validation\Rules\Traits;

use Exception;

trait DateUtils
trait DateUtilsTrait
{

/**
Expand All @@ -26,9 +26,8 @@ protected function isValidDate(string $date): bool
*/
protected function throwException(string $value)
{
return new Exception(
"Expected a valid date, got '{$value}' instead. 2016-12-08, 2016-12-02 14:58, tomorrow are considered valid dates"
);
// phpcs:ignore
return new Exception("Expected a valid date, got '{$value}' instead. 2016-12-08, 2016-12-02 14:58, tomorrow are considered valid dates");
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ protected function resolveRules($rules): array
$validator = call_user_func_array($validatorFactory, ['callback', $rule]);
} else {
$ruleName = is_object($rule) ? get_class($rule) : gettype($rule);
throw new \Exception("Rule must be a string, closure or Rakit\Validation\Rule instance. ".$ruleName." given");
$message = "Rule must be a string, Closure or '".Rule::class."' instance. ".$ruleName." given";
throw new \Exception();
}

$resolvedRules[] = $validator;
Expand Down

0 comments on commit 9e1f8e6

Please sign in to comment.