GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 560332...66e815 )
by Robert
11:59
created

RadioButtonColumn::renderDataCellContent()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 10
cp 0.8
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 9
nc 8
nop 3
crap 5.2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\grid;
9
10
use Closure;
11
use yii\base\InvalidConfigException;
12
use yii\helpers\Html;
13
14
/**
15
 * RadioButtonColumn displays a column of radio buttons in a grid view.
16
 *
17
 * To add a RadioButtonColumn to the [[GridView]], add it to the [[GridView::columns|columns]] configuration as follows:
18
 *
19
 * ```php
20
 * 'columns' => [
21
 *     // ...
22
 *     [
23
 *         'class' => 'yii\grid\RadioButtonColumn',
24
 *         'radioOptions' => function ($model) {
25
 *              return [
26
 *                  'value' => $model['value'],
27
 *                  'checked' => $model['value'] == 2
28
 *              ];
29
 *          }
30
 *     ],
31
 * ]
32
 * ```
33
 *
34
 * @author Kirk Hansen <[email protected]>
35
 * @since 2.0.11
36
 */
37
class RadioButtonColumn extends Column
38
{
39
    /**
40
     * @var string the name of the input radio button input fields.
41
     */
42
    public $name = 'radioButtonSelection';
43
    /**
44
     * @var array|\Closure the HTML attributes for the radio buttons. This can either be an array of
45
     * attributes or an anonymous function ([[Closure]]) returning such an array.
46
     *
47
     * The signature of the function should be as follows: `function ($model, $key, $index, $column)`
48
     * where `$model`, `$key`, and `$index` refer to the model, key and index of the row currently being rendered
49
     * and `$column` is a reference to the [[RadioButtonColumn]] object.
50
     *
51
     * A function may be used to assign different attributes to different rows based on the data in that row.
52
     * Specifically if you want to set a different value for the radio button you can use this option
53
     * in the following way (in this example using the `name` attribute of the model):
54
     * ```php
55
     * 'radioOptions' => function ($model, $key, $index, $column) {
56
     *     return ['value' => $model->attribute];
57
     * }
58
     * ```
59
     * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
60
     */
61
    public $radioOptions = [];
62
63
64
    /**
65
     * @inheritdoc
66
     * @throws \yii\base\InvalidConfigException if [[name]] is not set.
67
     */
68 4
    public function init()
69
    {
70 4
        parent::init();
71 4
        if (empty($this->name)) {
72 1
            throw new InvalidConfigException('The "name" property must be set.');
73
        }
74 3
    }
75
76
    /**
77
     * @inheritdoc
78
     */
79 3
    protected function renderDataCellContent($model, $key, $index)
80
    {
81 3
        if ($this->radioOptions instanceof Closure) {
82 2
            $options = call_user_func($this->radioOptions, $model, $key, $index, $this);
83 2
        } else {
84 1
            $options = $this->radioOptions;
85 1
            if (!isset($options['value'])) {
86
                $options['value'] = is_array($key) ? json_encode($key, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $key;
87
            }
88
        }
89 3
        $checked = isset($options['checked']) ? $options['checked'] : false;
90 3
        return Html::radio($this->name, $checked, $options);
91
    }
92
}
93