Skip to content

Commit

Permalink
Traits Bugs Fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
steevenz committed Feb 27, 2018
1 parent f5b30b8 commit ae86115
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Traits/Collectors/ConfigCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function addConfig( $key, $value )
} else {
$this->config[ $key ] = $value;
}
} else {
$this->config[ $key ] = $value;
}

return $this;
Expand Down Expand Up @@ -103,6 +105,8 @@ public function setConfig( $key, $value = null )
} else {
$this->config[ $key ] = $value;
}
} else {
$this->config[ $key ] = $value;
}

return $this;
Expand Down
53 changes: 50 additions & 3 deletions src/Traits/Collectors/ErrorCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,45 @@

// ------------------------------------------------------------------------

/**
* Trait ErrorCollectorTrait
* @package O2System\Spl\Traits\Collectors
*/
trait ErrorCollectorTrait
{
/**
* ErrorCollectorTrait::$errors
*
* List of errors.
*
* @var array
*/
private $errors = [];

// ------------------------------------------------------------------------

public function setErrors( array $errors )
/**
* ErrorCollectorTrait::setErrors
*
* Sets errors.
*
* @param array $errors
*/
protected function setErrors( array $errors )
{
$this->errors = $errors;
}

// ------------------------------------------------------------------------

public function addErrors( array $errors )
/**
* ErrorCollectorTrait::addErrors
*
* Adds errors.
*
* @param array $errors
*/
protected function addErrors( array $errors )
{
foreach ( $errors as $error ) {
$this->addError( $error[ 'code' ], $error[ 'message' ] );
Expand All @@ -36,8 +61,30 @@ public function addErrors( array $errors )

// ------------------------------------------------------------------------

public function addError( $code, $message )
/**
* ErrorCollectorTrait::addError
*
* Add error.
*
* @param int $code Error code.
* @param string $message Error message.
*/
protected function addError( $code, $message )
{
$this->errors[ $code ] = $message;
}

// ------------------------------------------------------------------------

/**
* ErrorCollectorTrait
*
* Gets errors.
*
* @return array
*/
public function getErrors()
{
return $this->errors;
}
}

0 comments on commit ae86115

Please sign in to comment.