|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Stu\Lib\Interaction; |
|
4
|
|
|
|
|
5
|
|
|
use Override; |
|
|
|
|
|
|
6
|
|
|
use Stu\Lib\Information\InformationInterface; |
|
7
|
|
|
use Stu\Lib\Interaction\Member\InteractionMemberInterface; |
|
8
|
|
|
|
|
9
|
|
|
class CustomizedInteractionChecker implements CustomizedInteractionCheckerInterface |
|
10
|
|
|
{ |
|
11
|
|
|
private InteractionMemberInterface $source; |
|
12
|
|
|
private InteractionMemberInterface $target; |
|
13
|
|
|
|
|
14
|
|
|
/** @var array<InteractionCheckType> */ |
|
15
|
|
|
private array $checkTypes; |
|
16
|
|
|
|
|
17
|
15 |
|
public function setSource(InteractionMemberInterface $source): void |
|
18
|
|
|
{ |
|
19
|
15 |
|
$this->source = $source; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
15 |
|
public function setTarget(InteractionMemberInterface $target): void |
|
23
|
|
|
{ |
|
24
|
15 |
|
$this->target = $target; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** @param array<InteractionCheckType> $checkTypes */ |
|
28
|
15 |
|
public function setCheckTypes(array $checkTypes): void |
|
29
|
|
|
{ |
|
30
|
15 |
|
$this->checkTypes = $checkTypes; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
15 |
|
#[Override] |
|
34
|
|
|
public function check(InformationInterface $information): bool |
|
35
|
|
|
{ |
|
36
|
15 |
|
$targetUser = $this->target->getUser(); |
|
37
|
|
|
if ( |
|
38
|
15 |
|
$this->shouldCheck(InteractionCheckType::EXPECT_TARGET_NO_VACATION) |
|
39
|
15 |
|
&& $targetUser !== null |
|
40
|
15 |
|
&& $targetUser->isVacationRequestOldEnough() |
|
41
|
|
|
) { |
|
42
|
|
|
$information->addInformation(InteractionCheckType::EXPECT_TARGET_NO_VACATION->getReason()); |
|
43
|
|
|
return false; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
15 |
|
if ($this->source->getLocation() !== $this->target->getLocation()) { |
|
47
|
|
|
return false; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
15 |
|
$refused = $this->source->canAccess( |
|
51
|
15 |
|
$this->target, |
|
52
|
15 |
|
fn(InteractionCheckType $checkType): bool => $this->shouldCheck($checkType) |
|
53
|
15 |
|
); |
|
54
|
15 |
|
if ($refused !== null) { |
|
55
|
|
|
$information->addInformation($refused->getReason()); |
|
56
|
|
|
return false; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
15 |
|
$refused = $this->target->canBeAccessedFrom( |
|
60
|
15 |
|
$this->source, |
|
61
|
15 |
|
fn(InteractionCheckType $checkType): bool => $this->shouldCheck($checkType) |
|
62
|
15 |
|
); |
|
63
|
15 |
|
if ($refused !== null) { |
|
64
|
|
|
$information->addInformation($refused->getReason()); |
|
65
|
|
|
return false; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
15 |
|
return true; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
15 |
|
private function shouldCheck(InteractionCheckType $checkType): bool |
|
72
|
|
|
{ |
|
73
|
15 |
|
return in_array($checkType, $this->checkTypes); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths