Apply the callback if the value is truthy.

@param  bool $value
@param  callable $callback
@return mixed
435911
public function when($value, callable $callback): CollectionInterface
    {
        if ($value) {
            $this->generator = $callback($this)->generator;
        }

        return $this;
    }
758323
public function apply(callable $callback)
    {
        foreach ($this->pairs as &$pair) {
            $pair->value = $callback($pair->key, $pair->value);
        }
    }
766675
final protected function validateCallable($value, array $allowed) : bool
    {
        if (true === in_array('callable', $allowed)) {
            if (true === is_callable($value)) {
                return true;
            }
        }

        return false;
    }
1034488
public function filterByValueLike($value)
    {
        $callback = function (BindingInterface $binding, $key) use ($value) {
            return strpos($binding->getValue(), $value) !== false;
        };

        return $this->filter($callback);
    }
670451
public function _reject($value) {
        if ($this->state === self::PENDING) {
            $this->value = $value;
            for ($i = 0; $i < count($this->failure_pending); $i++) {
                $callback = $this->failure_pending[$i];
                $callback($value);
            }
            $this->state = self::REJECTED;
        }
    }
628007
public function reverseTransform($value)
    {
        if (null === $value) {
            return false;
        }

        if (!is_bool($value)) {
            throw new UnexpectedTypeException($value, 'Boolean');
        }

        return true === $value ? $this->trueValue : null;
    }
998006
public function whereExists(Closure $callback, $boolean = 'and', $not = false)
    {
        $type = $not ? 'NotExists' : 'Exists';

        $query = $this->newQuery();

        //
        call_user_func($callback, $query);

        $this->wheres[] = compact('type', 'operator', 'query', 'boolean');

        $this->mergeBindings($query);

        return $this;
    }
580643
public function setCallback($callback)
    {
        if (!$callback instanceof Closure) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Invalid parameter for callback: must be %s',
                Closure::class
            ));
        }

        return parent::setCallback($callback);
    }
1053619
private function getCallable($value)
    {
        if (is_string($value) || is_object($value)) {
            return $this->validateCallable([$value]);
        } elseif (is_array($value) && count($value) === 1 && isset($value[0])) {
            return $this->validateCallable($value);
        } elseif (is_array($value) && count($value) === 2 && isset($value[0]) && isset($value[1]) && is_array($value[1])) {
            return $this->validateCallable($value);
        } elseif (is_array($value) && count($value) === 2 && isset($value[0]) && isset($value[1])) {
            return $this->validateCallable([$value]);
        } elseif (is_array($value) && count($value) === 3 && isset($value[0]) && isset($value[1]) && isset($value[2])) {
            return $this->validateCallable([[$value[0], $value[1]], $value[2]]);
        }

        return false;
    }
893817
public function filterByValue($value)
    {
        $callback = function (BindingInterface $binding, $key) use ($value) {
            return $binding->getValue() == $value;
        };

        return $this->filter($callback);
    }
457542
public static function transform($value, callable $callback, $default = null)
    {
        if (self::filled($value)) {
            return $callback($value);
        }

        if (\is_callable($default)) {
            return $default($value);
        }

        return $default;
    }
948503
public function parseBooleanValue($value)
    {
        if (is_bool($value)) {
            return $value;
        }
        switch (strtolower($value)) {
            case 'true':
                return true;
            case 'false':
                return false;
        }

        throw new RuntimeException("Unknown boolean value '{$value}'.");
    }
486958
protected function _validate_bool($value)
    {
        $trueValues = ['1', 'true'];
        $falseValues = ['0', 'false'];

        if (in_array($value, $trueValues, true)) {
            return true;
        } elseif (in_array($value, $falseValues, true)) {
            return false;
        } else {
            return null;
        }
    }
427934
public function AssignCallback($Callback, $Options = NULL) {
      if (!is_callable($Callback)) return FALSE;
      
      $this->Callback = $Callback;
      $this->CallbackOptions = $Options;
   }
1271484
protected function castToBool($value, bool $nullable = true)
    {
        if (null === $value && $nullable) {
            return null;
        }

        return (bool) $value;
    }
274794
public function when($condition, callable $trueCallback, callable $falseCallback = null)
    {
        if ($condition) {
            call_user_func($trueCallback, $this);
        } else {
            is_callable($falseCallback) && call_user_func($falseCallback, $this);
        }
        return $this;
    }
826907
public function action(callable $value = null)
    {
        if (null === $value) {
            return $this->action;
        }
        $this->action = $value;
        return $this;
    }