예제 #1
0
 public function closure()
 {
     return \Lead\Filter\Filters::run(isset($this) ? $this : get_called_class(), __FUNCTION__, func_get_args(), function ($next) {
         return function () {
             $rand = rand(2, 5);
             $rand++;
             return $rand;
         };
     });
 }
예제 #2
0
            Interceptor::load($previous);
        });
        it("throws an exception when no autoloader are available", function () {
            $loaders = spl_autoload_functions();
            foreach ($loaders as $loader) {
                spl_autoload_unregister($loader);
            }
            try {
                Filters::patch();
                $success = true;
            } catch (Exception $e) {
                $success = $e->getMessage();
            }
            foreach ($loaders as $loader) {
                spl_autoload_register($loader);
            }
            expect($success)->toBe('Unable to find a valid autoloader to apply the JIT filter patcher.');
        });
    });
    describe("::unpatch()", function () {
        it("bails out when the filter JIT patcher is not enabled", function () {
            expect(Filters::unpatch())->toBe(true);
        });
    });
    describe("::reset()", function () {
        it("clears all the filters", function () {
            Filters::reset();
            expect(Filters::get())->toBe([]);
        });
    });
});
예제 #3
0
 public function filterable()
 {
     return Filters::run($this, 'filterable', func_get_args(), function ($next, $message) {
         return "Hello {$message}";
     });
 }