FileUpload   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 45
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B infos() 0 29 4
A preview() 0 12 1
1
<?php
2
3
/*
4
 * This file is part of the Icybee package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Icybee\Modules\Files;
13
14
use Brickrouge\Element;
15
use ICanBoogie\I18n;
16
17
class FileUpload extends \Brickrouge\File
18
{
19
	protected function infos()
20
	{
21
		$path = $this['value'];
22
		$details = $this->details($path);
23
		$preview = $this->preview($path);
24
25
		$rc = '';
26
27
		if ($preview)
28
		{
29
			$rc .= '<div class="preview">';
30
			$rc .= $preview;
31
			$rc .= '</div>';
32
		}
33
34
		if ($details)
0 ignored issues
show
Bug Best Practice introduced by
The expression $details of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
35
		{
36
			$rc .= '<ul class="details">';
37
38
			foreach ($details as $detail)
39
			{
40
				$rc .= '<li>' . $detail . '</li>';
41
			}
42
43
			$rc .= '</ul>';
44
		}
45
46
		return $rc;
47
	}
48
49
	protected function preview($path)
50
	{
51
		return new Element('a', [
52
53
			Element::INNER_HTML => '',
54
55
			'class' => "icon-download-alt",
56
			'href' => $path,
57
			'title' => $this->t('download', [], [ 'scope' => 'fileupload.element' ])
58
59
		]);
60
	}
61
}
62