Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Pull Request — master (#1094)
by Dan
05:37
created

DatabaseRecord::getBoolean()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
class DatabaseRecord {
6
7
	/**
8
	 * @param array $dbRecord A record from a DatabaseResult.
9
	 */
10
	public function __construct(
11
		private array $dbRecord
12
	) {}
13
14
	public function hasField(string $name) : bool {
15
		return isset($this->dbRecord[$name]);
16
	}
17
18
	public function getField(string $name) : ?string {
19
		return $this->dbRecord[$name];
20
	}
21
22
	public function getBoolean(string $name) : bool {
23
		return match($this->dbRecord[$name]) {
24
			'TRUE' => true,
25
			'FALSE' => false,
26
		};
27
	}
28
29
	public function getInt(string $name) : int {
30
		return (int)$this->dbRecord[$name];
31
	}
32
33
	public function getFloat(string $name) : float {
34
		return (float)$this->dbRecord[$name];
35
	}
36
37
	public function getMicrotime(string $name) : string {
38
		// All digits of precision are stored in a MySQL bigint
39
		$data = $this->dbRecord[$name];
40
		return sprintf('%f', $data / 1E6);
41
	}
42
43
	public function getObject(string $name, bool $compressed = false, bool $nullable = false) : mixed {
44
		$object = $this->getField($name);
45
		if ($nullable === true && $object === null) {
46
			return null;
47
		}
48
		if ($compressed === true) {
49
			$object = gzuncompress($object);
0 ignored issues
show
Bug introduced by
It seems like $object can also be of type null; however, parameter $data of gzuncompress() 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

49
			$object = gzuncompress(/** @scrutinizer ignore-type */ $object);
Loading history...
50
		}
51
		return unserialize($object);
0 ignored issues
show
Bug introduced by
It seems like $object can also be of type null; however, parameter $data of unserialize() 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

51
		return unserialize(/** @scrutinizer ignore-type */ $object);
Loading history...
52
	}
53
54
	public function getRow() : array {
55
		return $this->dbRecord;
56
	}
57
58
}
59