From dafd3601526a7a380e7c4f815bf321499f1625ce Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sat, 28 Dec 2013 16:35:06 -0500 Subject: [PATCH] CS fixes. --- extensions/yii/debug/components/search/Filter.php | 9 +++---- .../yii/debug/components/search/matches/Exact.php | 4 ++-- extensions/yii/debug/models/search/Debug.php | 28 ++++++++++++---------- extensions/yii/debug/views/default/index.php | 13 ++++++---- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/extensions/yii/debug/components/search/Filter.php b/extensions/yii/debug/components/search/Filter.php index 85c30ee..557e12c 100644 --- a/extensions/yii/debug/components/search/Filter.php +++ b/extensions/yii/debug/components/search/Filter.php @@ -35,8 +35,7 @@ class Filter extends Component { $filtered = []; - foreach($data as $row) - { + foreach ($data as $row) { if ($this->checkFilter($row)) { $filtered[] = $row; } @@ -53,14 +52,12 @@ class Filter extends Component { $matched = true; - foreach ($row as $name=>$value) - { + foreach ($row as $name => $value) { if (isset($this->rules[$name])) { #check all rules for given attribute - foreach($this->rules[$name] as $rule) - { + foreach ($this->rules[$name] as $rule) { if (!$rule->check($value)) { $matched = false; } diff --git a/extensions/yii/debug/components/search/matches/Exact.php b/extensions/yii/debug/components/search/matches/Exact.php index 40a9bcc..34bb0cd 100644 --- a/extensions/yii/debug/components/search/matches/Exact.php +++ b/extensions/yii/debug/components/search/matches/Exact.php @@ -8,7 +8,7 @@ namespace yii\debug\components\search\matches; /** - * + * * @author Mark Jebri * @since 2.0 */ @@ -27,7 +27,7 @@ class Exact extends Base public function check($value) { if (!$this->partial) { - return (mb_strtolower($this->value,'utf8') == mb_strtolower($value,'utf8')); + return (mb_strtolower($this->value, 'utf8') == mb_strtolower($value, 'utf8')); } else { return (mb_strpos($value, $this->value) !== false); } diff --git a/extensions/yii/debug/models/search/Debug.php b/extensions/yii/debug/models/search/Debug.php index 27bed49..f89990f 100644 --- a/extensions/yii/debug/models/search/Debug.php +++ b/extensions/yii/debug/models/search/Debug.php @@ -38,7 +38,7 @@ class Debug extends Model public $url; /** - * @var string status code attribute input search value + * @var string status code attribute input search value */ public $statusCode; @@ -56,7 +56,7 @@ class Debug extends Model public function rules() { return [ - [['tag', 'ip', 'method', 'ajax', 'url','statusCode','sqlCount'], 'safe'], + [['tag', 'ip', 'method', 'ajax', 'url', 'statusCode', 'sqlCount'], 'safe'], ]; } @@ -78,8 +78,8 @@ class Debug extends Model /** * Returns data provider with filled models. Filter applied if needed. - * @param type $params - * @param type $models + * @param array $params + * @param array $models * @return \yii\data\ArrayDataProvider */ public function search($params, $models) @@ -87,7 +87,7 @@ class Debug extends Model $dataProvider = new ArrayDataProvider([ 'allModels' => $models, 'sort' => [ - 'attributes' => ['method', 'ip','tag','time','statusCode','sqlCount'], + 'attributes' => ['method', 'ip', 'tag', 'time', 'statusCode', 'sqlCount'], ], 'pagination' => [ 'pageSize' => 10, @@ -121,25 +121,29 @@ class Debug extends Model return in_array($code, $this->criticalCodes); } - public function addCondition($filter,$attribute,$partial=false) + /** + * @param Filter $filter + * @param string $attribute + * @param boolean $partial + */ + public function addCondition($filter, $attribute, $partial = false) { $value = $this->$attribute; - if (mb_strpos($value, '>') !== false) - { + if (mb_strpos($value, '>') !== false) { $value = intval(str_replace('>', '', $value)); - $filter->addMatch($attribute,new matches\Greater(['value' => $value])); + $filter->addMatch($attribute, new matches\Greater(['value' => $value])); } elseif (mb_strpos($value, '<') !== false) { $value = intval(str_replace('<', '', $value)); - $filter->addMatch($attribute,new matches\Lower(['value' => $value])); + $filter->addMatch($attribute, new matches\Lower(['value' => $value])); } else { - $filter->addMatch($attribute,new matches\Exact(['value' => $value, 'partial' => $partial])); + $filter->addMatch($attribute, new matches\Exact(['value' => $value, 'partial' => $partial])); } } - + } diff --git a/extensions/yii/debug/views/default/index.php b/extensions/yii/debug/views/default/index.php index 9164205..73f5237 100644 --- a/extensions/yii/debug/views/default/index.php +++ b/extensions/yii/debug/views/default/index.php @@ -1,6 +1,5 @@ title = 'Yii Debugger'; @@ -30,10 +31,12 @@ $timeFormatter = extension_loaded('intl') ? Yii::createObject(['class' => 'yii\i echo GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, - 'rowOptions' => function ($model, $key, $index, $grid) use ($searchModel) - { - if ($searchModel->isCodeCritical($model['statusCode'])) + 'rowOptions' => function ($model, $key, $index, $grid) use ($searchModel) { + if ($searchModel->isCodeCritical($model['statusCode'])) { return ['class'=>'danger']; + } else { + return []; + } }, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], @@ -72,7 +75,7 @@ echo GridView::widget([ 'url', [ 'attribute' => 'statusCode', - 'filter' => [200=>200, 404=>404, 403=>403, 500=>500], + 'filter' => [200 => 200, 404 => 404, 403 => 403, 500 => 500], 'label' => 'Status code' ], ],