| Conditions | 6 |
| Paths | 16 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | public function __invoke (Twig_Environment $env, $assetPath) |
||
| 11 | { |
||
| 12 | $globals = $env->getGlobals(); |
||
| 13 | |||
| 14 | if ($assetPath instanceof JailObject) { |
||
| 15 | $assetPath = $assetPath->getPermalink(); |
||
|
|
|||
| 16 | } |
||
| 17 | else if (is_array($assetPath)) { |
||
| 18 | $assetPath = $assetPath['permalink']; |
||
| 19 | } |
||
| 20 | else if (is_null($assetPath)) { |
||
| 21 | $assetPath = '/'; |
||
| 22 | } |
||
| 23 | |||
| 24 | // @TODO 1.0.0 Remove support for 'base' as it's been deprecated |
||
| 25 | $base = (array_key_exists('base', $globals['site'])) ? $globals['site']['base'] : $globals['site']['baseurl']; |
||
| 26 | |||
| 27 | $baseURL = (empty($base)) ? '/' : '/' . trim($base, '/') . '/'; |
||
| 28 | $url = ltrim($assetPath, '/'); |
||
| 29 | |||
| 30 | return ($baseURL . $url); |
||
| 31 | } |
||
| 32 | |||
| 39 | } |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: