TeacherFirstCharacterStrategy::areEqualKeys()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 2
rs 10
ccs 0
cts 1
cp 0
cc 1
nc 1
nop 3
crap 2
1
<?php
2
3
namespace App\Grouping;
4
5
use App\Entity\Teacher;
6
7
class TeacherFirstCharacterStrategy implements GroupingStrategyInterface {
8
9
    /**
10
     * @param Teacher $object
11
     * @return string
12
     */
13
    public function computeKey($object, array $options = [ ]) {
14
        return ucfirst(substr($object->getAcronym(), 0, 1));
0 ignored issues
show
Bug introduced by
It seems like $object->getAcronym() can also be of type null; however, parameter $string of substr() 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

14
        return ucfirst(substr(/** @scrutinizer ignore-type */ $object->getAcronym(), 0, 1));
Loading history...
15
    }
16
17
    /**
18
     * @param string $keyA
19
     * @param string $keyB
20
     */
21
    public function areEqualKeys($keyA, $keyB, array $options = [ ]): bool {
22
        return $keyA === $keyB;
23
    }
24
25
    /**
26
     * @param string $key
27
     */
28
    public function createGroup($key, array $options = [ ]): GroupInterface {
29
        return new TeacherFirstCharacterGroup($key);
30
    }
31
}