ArticleQuery   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 51
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 6 2
A one() 0 3 1
A all() 0 3 1
A search() 0 10 1
1
<?php
2
namespace carono\exchange1c\models\query\base;
3
4
use carono\yii2helpers\QueryHelper;
0 ignored issues
show
Bug introduced by
The type carono\yii2helpers\QueryHelper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use yii\data\ActiveDataProvider;
6
use yii\data\Sort;
7
8
/**
9
 * This is the ActiveQuery class for \carono\exchange1c\models\Article
10
 * @see \carono\exchange1c\models\Article
11
 */
12
class ArticleQuery extends \yii\db\ActiveQuery
13
{
14
	/**
15
	 * @inheritdoc
16
	 * @return \carono\exchange1c\models\Article[]
17
	 */
18
	public function all($db = null)
19
	{
20
		return parent::all($db);
21
	}
22
23
24
	/**
25
	 * @inheritdoc
26
	 * @return \carono\exchange1c\models\Article
27
	 */
28
	public function one($db = null)
29
	{
30
		return parent::one($db);
0 ignored issues
show
Bug Best Practice introduced by
The expression return parent::one($db) also could return the type array which is incompatible with the documented return type carono\exchange1c\models\Article.
Loading history...
31
	}
32
33
34
	/**
35
	 * @var mixed $filter
36
	 * @var array $options Options for ActiveDataProvider
37
	 * @return ActiveDataProvider
38
	 */
39
	public function search($filter = null, $options = [])
40
	{
41
		$query = clone $this;
42
		$query->filter($filter);
43
		$sort = new Sort();
44
		    return new ActiveDataProvider(
45
		    array_merge([
46
		        'query' => $query,
47
		        'sort'  => $sort
48
		    ], $options)
49
		);
50
	}
51
52
53
	/**
54
	 * @var mixed $model
55
	 * @return $this
56
	 */
57
	public function filter($model = null)
58
	{
59
		if ($model){
60
		    QueryHelper::regular($model, $this);
61
		}
62
		return $this;
63
	}
64
}
65