Hoa central
Public Member Functions | Protected Attributes | List of all members
Hoa\Core\Exception\Group Class Reference
Inheritance diagram for Hoa\Core\Exception\Group:

Public Member Functions

 __construct ($message, $code=0, $arguments=[],\Exception $previous=null)
 
 raise ($previous=false)
 
 beginTransaction ()
 
 rollbackTransaction ()
 
 commitTransaction ()
 
 hasUncommittedExceptions ()
 
 offsetExists ($index)
 
 offsetGet ($index)
 
 offsetSet ($index, $exception)
 
 offsetUnset ($index)
 
 getExceptions ()
 
 getIterator ()
 
 count ()
 
- Public Member Functions inherited from Hoa\Core\Exception\Exception
 __construct ($message, $code=0, $arguments=[], $previous=null)
 
 send ()
 
- Public Member Functions inherited from Hoa\Core\Exception\Idle
 __construct ($message, $code=0, $arguments=[],\Exception $previous=null)
 
 getBacktrace ()
 
 getPreviousThrow ()
 
 getArguments ()
 
 getRawMessage ()
 
 getFormattedMessage ()
 
 getFrom ()
 
 raise ($previous=false)
 
 __toString ()
 

Protected Attributes

 $_group = null
 
- Protected Attributes inherited from Hoa\Core\Exception\Idle
 $_tmpArguments = null
 
 $_arguments = null
 
 $_trace = null
 
 $_previous = null
 
 $_rawMessage = null
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\Core\Exception\Idle
static uncaught ($exception)
 
static error ($errno, $errstr, $errfile, $errline)
 

Detailed Description

Class .

This is an exception that contains a group of exceptions.

Definition at line 425 of file Exception.php.

Constructor & Destructor Documentation

Hoa\Core\Exception\Group::__construct (   $message,
  $code = 0,
  $arguments = [],
\Exception  $previous = null 
)

Create an exception.

Parameters
string$messageFormatted message.
int$codeCode (the ID).
array$argumentsArguments to format message.
\Exception$previousPrevious exception in chaining.
Returns
void

Definition at line 447 of file Exception.php.

452  {
453  parent::__construct($message, $code, $arguments, $previous);
454  $this->_group = new \SplStack();
455  $this->beginTransaction();
456 
457  return;
458  }

Here is the call graph for this function:

Member Function Documentation

Hoa\Core\Exception\Group::beginTransaction ( )

Begin a transaction.

Returns

Definition at line 492 of file Exception.php.

493  {
494  $this->_group->push(new \ArrayObject());
495 
496  return $this;
497  }

Here is the caller graph for this function:

Hoa\Core\Exception\Group::commitTransaction ( )

Commit a transaction.

Returns

Definition at line 520 of file Exception.php.

521  {
522  if (false === $this->hasUncommittedExceptions()) {
523  return $this;
524  }
525 
526  foreach ($this->_group->pop() as $index => $exception) {
527  $this->offsetSet($index, $exception);
528  }
529 
530  return $this;
531  }
offsetSet($index, $exception)
Definition: Exception.php:586

Here is the call graph for this function:

Hoa\Core\Exception\Group::count ( )

Count the number of committed exceptions.

Returns
int

Definition at line 646 of file Exception.php.

647  {
648  return count($this->_group->bottom());
649  }

Here is the caller graph for this function:

Hoa\Core\Exception\Group::getExceptions ( )

Get committed exceptions in the group.

Returns

Definition at line 626 of file Exception.php.

627  {
628  return $this->_group->bottom();
629  }

Here is the caller graph for this function:

Hoa\Core\Exception\Group::getIterator ( )

Get an iterator over all exceptions (committed or not).

Returns

Definition at line 636 of file Exception.php.

637  {
638  return $this->getExceptions()->getIterator();
639  }

Here is the call graph for this function:

Hoa\Core\Exception\Group::hasUncommittedExceptions ( )

Check if there is uncommitted exceptions.

Returns
bool

Definition at line 538 of file Exception.php.

539  {
540  return
541  1 < count($this->_group) &&
542  0 < count($this->_group->top());
543  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Core\Exception\Group::offsetExists (   $index)

Check if an index in the group exists.

Parameters
mixed$indexIndex.
Returns
bool

Definition at line 551 of file Exception.php.

552  {
553  foreach ($this->_group as $group) {
554  if (isset($group[$index])) {
555  return true;
556  }
557  }
558 
559  return false;
560  }
Hoa\Core\Exception\Group::offsetGet (   $index)

Get an exception from the group.

Parameters
mixed$indexIndex.
Returns

Definition at line 568 of file Exception.php.

569  {
570  foreach ($this->_group as $group) {
571  if (isset($group[$index])) {
572  return $group[$index];
573  }
574  }
575 
576  return null;
577  }
Hoa\Core\Exception\Group::offsetSet (   $index,
  $exception 
)

Set an exception in the group.

Parameters
mixed$indexIndex.
\Exception$exceptionException.
Returns
void

Definition at line 586 of file Exception.php.

587  {
588  if (!($exception instanceof \Exception)) {
589  return null;
590  }
591 
592  $group = $this->_group->top();
593 
594  if (null === $index ||
595  true === is_int($index)) {
596  $group[] = $exception;
597  } else {
598  $group[$index] = $exception;
599  }
600 
601  return;
602  }

Here is the caller graph for this function:

Hoa\Core\Exception\Group::offsetUnset (   $index)

Remove an exception in the group.

Parameters
mixed$indexIndex.
Returns
void

Definition at line 610 of file Exception.php.

611  {
612  foreach ($this->_group as $group) {
613  if (isset($group[$index])) {
614  unset($group[$index]);
615  }
616  }
617 
618  return;
619  }
Hoa\Core\Exception\Group::raise (   $previous = false)

Raise an exception as a string.

Parameters
bool$previousWhether raise previous exception if exists.
Returns
string

Definition at line 466 of file Exception.php.

467  {
468  $out = parent::raise($previous);
469 
470  if (0 >= count($this)) {
471  return $out;
472  }
473 
474  $out .= "\n\n" . 'Contains the following exceptions:';
475 
476  foreach ($this as $exception) {
477  $out .= "\n\n" . ' • ' . str_replace(
478  "\n",
479  "\n" . ' ',
480  $exception->raise($previous)
481  );
482  }
483 
484  return $out;
485  }

Here is the call graph for this function:

Hoa\Core\Exception\Group::rollbackTransaction ( )

Rollback a transaction.

Returns

Definition at line 504 of file Exception.php.

505  {
506  if (1 >= count($this->_group)) {
507  return $this;
508  }
509 
510  $this->_group->pop();
511 
512  return $this;
513  }

Here is the call graph for this function:

Member Data Documentation

Hoa\Core\Exception\Group::$_group = null
protected

Definition at line 434 of file Exception.php.


The documentation for this class was generated from the following file: