debug/Handler.php
public function apply($condition, callable $onMatch = null) : self
    {
         if (!is_callable($condition)) {
            if (!$condition instanceof Condition) {
                throw new \InvalidArgumentException('Expected a \nyx\diagnostics\Condition or a callable as first argument, got ['.diagnostics\Debug::getTypeName($condition).'] instead.');
            }

            $this->conditions[] = $condition;
        } else {
            // Both parameters are/should be callables.
            if (null === $onMatch) {
                throw new \InvalidArgumentException('A callable must be given as second parameter when the first is also a callable.');
            }

            $this->conditions[] = [
                'matcher' => $condition,
                'onMatch' => $onMatch
            ];
        }

        return $this;
    }
public function apply($condition, callable $onMatch = null) : self
    {
         if (!is_callable($condition)) {
            if (!$condition instanceof Condition) {
                throw new \InvalidArgumentException('Expected a \nyx\diagnostics\Condition or a callable as first argument, got ['.diagnostics\Debug::getTypeName($condition).'] instead.');
            }

            $this->conditions[] = $condition;
        } else {
            // Both parameters are/should be callables.
            if (null === $onMatch) {
                throw new \InvalidArgumentException('A callable must be given as second parameter when the first is also a callable.');
            }

            $this->conditions[] = [
                'matcher' => $condition,
                'onMatch' => $onMatch
            ];
        }

        return $this;
    }
public function apply ( $ condition , callable $ onMatch = null ) : self { if ( ! is_callable ( $ condition ) ) { if ( ! $ condition instanceof Condition ) { throw new \ InvalidArgumentException ( 'Expected a \nyx\diagnostics\Condition or a callable as first argument, got [' . diagnostics \ Debug :: getTypeName ( $ condition ) . '] instead.' ) ; } $ this -> conditions [ ] = $ condition ; } else { // Both parameters are/should be callables. if ( null === $ onMatch ) { throw new \ InvalidArgumentException ( 'A callable must be given as second parameter when the first is also a callable.' ) ; } $ this -> conditions [ ] = [ 'matcher' => $ condition , 'onMatch' => $ onMatch ] ; } return $ this ; }
Applies a Condition to this Handler.

@param   Condition|callable  $condition  Either a Condition instance or a 'matcher' callable accepting one
two arguments - an Exception and a Handler instance, and
returning true/false when the given Exception is a match or not.
When a callable is given, the second argument to this method must
also be given.
@param   callable            $onMatch    A callable containing the code that should be executed when the
'matcher' callable given as first argument returns true. This
argument is ignored when a concrete Condition instance is given
as the first argument instead of a callable.
@return  $this
@throws  \InvalidArgumentException       When a callable is given as first argument but the second is
missing or when neither a Condition instance nor a callable are
given as the first argument.
Applies a Condition to this Handler .