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

Passed
Push — main ( 6eb332...15a06a )
by Dan
07:01
created

UniGenLocationCategories   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A added() 0 2 1
A addLoc() 0 7 2
1
<?php declare(strict_types=1);
2
3
namespace Smr\Admin;
4
5
/**
6
 * Helper class for organizing Locations into categories.
7
 *
8
 * Though we expect a location to be only in one category, it is possible to
9
 * edit a location in the Admin Tools so that it is in two or more categories.
10
 * For simplicity here, it will only show up in the first category it matches,
11
 * but it will identify all other categories that it is in.
12
 * If multi-category locations becomes common, this code should be modified.
13
 */
14
class UniGenLocationCategories {
15
16
	/** @var array<string, array<int>> */
17
	public array $locTypes = [];
18
	/** @var array<int> */
19
	private array $locAdded = []; // list of locs added to a category
20
21
	public function addLoc(int $locID, string $category): string {
22
		if ($this->added($locID)) {
23
			return "<b>Also in $category</b><br />";
24
		}
25
		$this->locTypes[$category][] = $locID;
26
		$this->locAdded[] = $locID;
27
		return '';
28
	}
29
30
	public function added(int $locID): bool {
31
		return in_array($locID, $this->locAdded);
32
	}
33
34
}
35