ProvinceModel   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 38
c 0
b 0
f 0
rs 10
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A all() 0 17 1
1
<?php
2
3
namespace App\Models;
4
5
use Nette\Database\Context;
6
use Nette\Database\Table\ActiveRow;
7
8
class ProvinceModel extends BaseModel
9
{
10
11
	/**
12
	 * @var string
13
	 */
14
	protected $table = 'kk_provinces';
15
16
	/**
17
	 * @param Context $database
18
	 */
19
	public function __construct(Context $database)
20
	{
21
		$this->setDatabase($database);
22
	}
23
24
	/**
25
	 * @return array
26
	 */
27
	public function all(): array
28
	{
29
		$provinces = $this->getDatabase()
30
			->table($this->getTable())
31
			->select('id')
32
			->select('province_name')
33
			->where('deleted', '0')
34
			->fetchAll();
35
36
		array_walk($provinces, function(&$province, $key) {
0 ignored issues
show
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
37
			$province = $province->province_name;
38
		});
39
40
		$provinces[0] = 'zvolte kraj';
41
42
		return $provinces;
43
	}
44
45
}
46