SlideDefault::renderSlideHtml()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2
1
<?php
2
/**
3
 * Created on Wed Oct 28 2020.
4
 *
5
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
6
 * @copyright Copyright (c) 2010 - 2020 Sergey Coderius
7
 * @author Sergey Coderius <[email protected]>
8
 *
9
 * @see https://github.com/coderius - My github. See more my packages here...
10
 * @see https://coderius.biz.ua/ - My dev. blog
11
 *
12
 * Contact email: [email protected] - Have suggestions, contact me |:=)
13
 */
14
15
namespace coderius\swiperslider;
16
17
use Closure;
18
use yii\base\BaseObject;
19
use yii\helpers\Html;
20
21
 class SlideDefault extends BaseObject
22
 {
23
     /**
24
      * @var SwiperSlider widget object that owns this slide.
25
      */
26
     public $slider;
27
     /**
28
      * @var array the HTML attributes for the slide tag.
29
      *
30
      * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
31
      */
32
     public $options = [];
33
     /**
34
      * Vilue contain all content pasted from tag.
35
      *
36
      * @var string
37
      */
38
     public $value = '';
39
40
     /**
41
      * Undocumented function.
42
      *
43
      * @param string $tag
44
      * @param int    $index $index the zero-based index of the data item among the item array returned by [[SwiperSlider::makeHtml]]
45
      *
46
      * @return string
47
      */
48 3
     public function renderSlideHtml($tag, $index)
49
     {
50 3
         $content = $this->value;
0 ignored issues
show
Unused Code introduced by
$content is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
51 3
         if ($this->value instanceof Closure) {
52 3
             $content = call_user_func($this->value, $tag, $index, $this);
53 1
         } else {
54 3
             $content = $this->value;
55
         }
56
57 3
         $options = $this->options;
58
59 3
         return Html::tag($tag, $content, $options);
60
     }
61
 }
62