Test Failed
Push — master ( ecae19...f3c0e1 )
by Iman
05:24
created

CacheMiddleware::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\Middlewarize;
4
5
use Illuminate\Support\Facades\Cache;
6
7
class CacheMiddleware
8
{
9
    public function handle($data, $next, $key, $ttl)
10
    {
11
        $ttl = \DateInterval::createFromDateString($ttl);
12
        return Cache::remember($key, $ttl, function () use ($next, $data) {
13
            return $next($data);
14
        });
15
    }
16
}