Conditions | 7 |
Paths | 7 |
Total Lines | 31 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
11 | public static function handle($arguments, $content, ShortcodeParser $parser, $tag, array $extra = array()) |
||
12 | { |
||
13 | if (!empty($arguments['id'])) { |
||
14 | $document = DMSDocument::get()->byID($arguments['id']); |
||
15 | |||
16 | if ($document && !$document->isHidden()) { |
||
17 | if ($content) { |
||
18 | return sprintf( |
||
19 | '<a href="%s">%s</a>', |
||
20 | $document->Link(), |
||
21 | $parser->parse($content) |
||
22 | ); |
||
23 | } |
||
24 | |||
25 | if (isset($extra['element'])) { |
||
26 | $extra['element']->setAttribute('data-ext', $document->getExtension()); |
||
27 | $extra['element']->setAttribute('data-size', $document->getFileSizeFormatted()); |
||
28 | } |
||
29 | |||
30 | return $document->Link(); |
||
31 | } |
||
32 | } |
||
33 | |||
34 | $error = ErrorPage::get()->filter('ErrorCode', '404')->First(); |
||
35 | |||
36 | if ($error) { |
||
37 | return $error->Link(); |
||
38 | } |
||
39 | |||
40 | return ''; |
||
41 | } |
||
42 | } |
||
43 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.