| Conditions | 7 |
| Paths | 16 |
| Total Lines | 20 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 7.2269 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 16 | public function normalize($widget): void |
|
| 16 | { |
||
| 17 | 16 | if (! property_exists($widget, 'cacheLifeTime')) { |
|
| 18 | 13 | $M = config('widgetize.default_cache_lifetime', 0); |
|
| 19 | 13 | $widget->cacheLifeTime = $this->makeFromSeconds($M* 60); |
|
| 20 | } |
||
| 21 | |||
| 22 | 16 | if($widget->cacheLifeTime === 0) { |
|
| 23 | 1 | $widget->cacheLifeTime = $this->makeFromSeconds(0); |
|
| 24 | } |
||
| 25 | |||
| 26 | 16 | if (is_object($widget->cacheLifeTime)) { |
|
| 27 | 14 | return; |
|
| 28 | } |
||
| 29 | |||
| 30 | 2 | if ($widget->cacheLifeTime === 'forever' || $widget->cacheLifeTime < 0) { |
|
| 31 | // 2 weeks which is long enough ! |
||
| 32 | 2 | $widget->cacheLifeTime = $this->makeFromSeconds(1209600); |
|
| 33 | } elseif (is_numeric($widget->cacheLifeTime)) { |
||
| 34 | $widget->cacheLifeTime = $this->makeFromSeconds($widget->cacheLifeTime * 60); |
||
| 35 | } |
||
| 43 |