Completed
Push — master ( 47c098...6c95d6 )
by smiley
02:23
created

CharsetTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _charset() 0 11 2
A _collate() 0 9 2
1
<?php
2
/**
3
 * Trait CharsetTrait
4
 *
5
 * @filesource   CharsetTrait.php
6
 * @created      05.06.2017
7
 * @package      chillerlan\Database\Query\Traits
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Query\Traits;
14
15
trait CharsetTrait{
16
17
	protected $collate;
18
19
	protected function _charset(string $collation):string {
20
		list($charset) = explode('_', $collation);
21
22
		$collate = 'CHARACTER SET '.$charset;
23
24
		if($charset !== $collation){
25
			$collate .= ' COLLATE '.$collation;
26
		}
27
28
		return $collate;
29
	}
30
31
	protected function _collate(string $collation){
32
		$collation = trim($collation);
33
34
		if(!empty($collation)){
35
			$this->collate = $collation;
36
		}
37
38
		return $this;
39
	}
40
}
41