Issues (68)

src/Query/OnConflictTrait.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Trait OnConflictTrait
4
 *
5
 * @filesource   OnConflictTrait.php
6
 * @created      09.01.2018
7
 * @package      chillerlan\Database\Query
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2018 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Query;
14
15
trait OnConflictTrait{
16
17
	protected string $name;
18
	protected ?string $on_conflict = null;
19
	protected ?string $conflict_target = null;
20
21
	/**
22
	 * @param string      $name
23
	 * @param string|null $on_conflict
24
	 * @param string|null $conflict_target
25
	 *
26
	 * @return $this
27
	 * @throws \chillerlan\Database\Query\QueryException
28
	 */
29
	public function name(string $name, string $on_conflict = null, string $conflict_target = null):Statement{
30
		$this->name      = trim($name);
31
		$on_conflict     = trim(strtoupper($on_conflict));
0 ignored issues
show
It seems like $on_conflict can also be of type null; however, parameter $string of strtoupper() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
		$on_conflict     = trim(strtoupper(/** @scrutinizer ignore-type */ $on_conflict));
Loading history...
32
		$conflict_target = trim(strtoupper($conflict_target));
33
34
		if(empty($this->name)){
35
			throw new QueryException('no name specified');
36
		}
37
38
		if(!empty($on_conflict)){
39
			$this->on_conflict = $on_conflict;
40
		}
41
42
		if(!empty($conflict_target)){
43
			$this->conflict_target = $conflict_target;
44
		}
45
46
		return $this;
47
	}
48
49
}
50