for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Date: 01.12.15
*
* @author Portey Vasil <[email protected]>
*/
namespace Youshido\GraphQL\Validator\ErrorContainer;
trait ErrorContainerTrait
{
/** @var \Exception[] */
protected $errors = [];
public function addError(\Exception $exception)
$this->errors[] = $exception;
}
public function hasErrors()
return !empty($this->errors);
public function getErrors()
return $this->errors;
public function getErrorsArray()
$errors = [];
foreach ($this->errors as $error) {
$errors[] = is_object($error) ? $error->getMessage() : $error;
return $errors;
public function clearErrors()
$this->errors = [];
return $this;