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