Skip to content

Commit

Permalink
Updated doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dyer, Andy committed Aug 15, 2018
1 parent d03ebf1 commit c1728c7
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,59 @@
use Respect\Validation\Exceptions\NestedValidationException;

/**
* Class Validator
*
* @author Andrew Dyer <[email protected]>
* @category Validation
* @see https://github.com/andrewdyer/slim3-validator
* Class Validator.
*/
class Validator
{

/** @var array */
private $_errors = [];

/**
*
* @return array
*/
public function getErrors()
public function getErrors(): array
{
return $this->_errors;
}

/**
*
* @return boolean
* @return bool
*/
public function hasPassed()
public function hasPassed(): bool
{
return empty($this->_errors);
}

/**
*
* @param string $key
* @param array $messages
* @param array $messages
*
* @return $this
*/
public function setErrors(string $key, array $messages)
public function setErrors(string $key, array $messages): self
{
$this->_errors[$key] = $messages;

return $this;
}

/**
*
* @param string $string
*
* @return string
*/
protected function formatName(string $string)
protected function formatName(string $string): string
{
return str_replace(["-", "_"], " ", ucfirst(strtolower($string)));
return str_replace(['-', '_'], ' ', ucfirst(strtolower($string)));
}

/**
*
* @param Request $request
* @param array $rules
* @param array $rules
*
* @return $this
*/
public function validate(Request $request, array $rules)
public function validate(Request $request, array $rules): self
{
foreach ($rules as $field => $validator) {
try {
Expand All @@ -78,5 +71,4 @@ public function validate(Request $request, array $rules)

return $this;
}

}

0 comments on commit c1728c7

Please sign in to comment.