Location: PHPKode > scripts > Anti_Util_CircularReference > anti_util_circularreference/Anti/Util/Exception.php
<?php
/**
 * @author  Christian Reinecke <hide@address.com>
 * @since   2009-04-30
 * @version 1.0
 */
class Anti_Util_CircularReference_Exception extends LogicException
{
    /**
     * @var array given waypoint pairs
     */
    protected $_waypoints;

    /**
     * @desc waypoint trace causing the CR
     * @var array
     */
    protected $_waypointTrace;

    /**
     * @param string $message
     * @param int $code
     * @param array $waypoints
     * @param array $causingRelativeStack
     */
    public function __construct($message, $code = 0, array $waypoints, array $waypointTrace)
    {
        parent::__construct($message, $code);

        $this->_waypoints         = $waypoints;
        $this->_waypointTrace = $waypointTrace;
    }

    /**
     * @return array waypoints
     */
    public function getWaypoints()
    {
        return $this->_waypoints;
    }

    /**
     * @return array full waypoints causing the circular reference
     */
    public function getWaypointTrace()
    {
        return $this->_waypointTrace;
    }

    /**
     * @return array exact section of waypoints causing the circular reference
     */
    public function getCausingWaypointTrace()
    {
        $causingTrace = array_reverse($this->_waypointTrace);
        $causingY     = $causingTrace[0]["waypoint"][1];
        $discard      = false;
        foreach ($causingTrace as $index => $trace) {
            if ($discard) {
                unset($causingTrace[$index]);
            } elseif ($trace["waypoint"][0] == $causingY) {
                $discard = true;
            }
        }
        $causingTrace = array_reverse($causingTrace);
        return $causingTrace;
    }
}
?>
Return current item: Anti_Util_CircularReference