public static function memoize(callable $provider)
    {
        return function () use ($provider) {
            static $result;
            static $isConstant;

            if ($isConstant) {
                return $result;
            }

            $isConstant = true;

            return $result = $provider();
        };
    }