SettlementsDatabaseQuery   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getSettlements() 0 6 1
A addressLevel() 0 10 2
1
<?php
2
3
namespace GeoFixer\models\queries;
4
5
/**
6
 * Class SettlementsDatabaseQuery
7
 *
8
 * @package GeoFixer\models\queries
9
 */
10
class SettlementsDatabaseQuery extends AbstractDatabaseQuery
11
{
12
    /**
13
     * SettlementsDatabaseQuery constructor.
14
     */
15 14
    public function __construct()
16
    {
17 14
        parent::__construct();
18 14
    }
19
20
    /**
21
     * Получаем города и поселения
22
     *
23
     * @return $this
24
     */
25 14
    public function getSettlements()
26
    {
27 14
        $this->db = $this->db->select([self::FIAS_CODE, self::TITLE, self::KLADR_CODE])->from('fias_address_object');
28
29 14
        return $this;
30
    }
31
32
    /**
33
     * Address level равен городу или поселению
34
     *
35
     * @param bool $full_settlements
36
     *
37
     * @return $this
38
     */
39 14
    public function addressLevel($full_settlements = false)
40
    {
41 14
        if ($full_settlements == false) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
42 9
            $this->db = $this->db->andWhere(['address_level' => self::CITY]);
43 9
        } else {
44 5
            $this->db = $this->db->andWhere(['OR' => [['address_level' => self::CITY], ['address_level' => self::SETTLEMENT]]]);
45
        }
46
47 14
        return $this;
48
    }
49
}
50