Passed
Push — master ( e0d6a2...2ec881 )
by Anton
05:25 queued 02:20
created

Count   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 4
1
<?php
2
3
/**
4
 * @package Cadmium\Framework\DB
5
 * @author Anton Romanov
6
 * @copyright Copyright (c) 2015-2017, Anton Romanov
7
 * @link http://cadmium-cms.com
8
 */
9
10
namespace DB\Query {
11
12
	use DB;
13
14
	class Count extends DB\Query {
15
16
		/**
17
		 * Constructor
18
		 */
19
20
		public function __construct(string $table, string $column = '*', bool $distinct = false, $condition = null) {
21
22
			# Process arguments
23
24
			$table = $this->getName($table);
25
26
			if ($column !== '*') $column = (($distinct ? 'DISTINCT ' : '') . $this->getName($column));
27
28
			$condition = $this->getString($condition, '^name IN $list', ' AND ');
29
30
			# Build query
31
32
			$this->query = ('SELECT COUNT(' . $column . ') as count ' .
33
34
				'FROM ' . $table . ($condition ? (' WHERE (' .  $condition . ')') : ''));
35
		}
36
	}
37
}
38