1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
require_once __DIR__.'/../vendor/autoload.php'; |
6
|
|
|
|
7
|
|
|
use Scalp\PatternMatching\CaseClass; |
8
|
|
|
use Scalp\PatternMatching\Deconstruction; |
9
|
|
|
use function Scalp\PatternMatching\match; |
10
|
|
|
use function Scalp\PatternMatching\Type; |
|
|
|
|
11
|
|
|
use function Scalp\PatternMatching\Any; |
|
|
|
|
12
|
|
|
use function Scalp\println; |
|
|
|
|
13
|
|
|
use function Scalp\papply; |
|
|
|
|
14
|
|
|
use const Scalp\__; |
|
|
|
|
15
|
|
|
use const Scalp\concat; |
|
|
|
|
16
|
|
|
|
17
|
|
|
abstract class Notification implements CaseClass |
18
|
|
|
{ |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
final class Email extends Notification |
22
|
|
|
{ |
23
|
|
|
use Deconstruction; |
24
|
|
|
|
25
|
|
|
private $sender; |
26
|
|
|
private $title; |
27
|
|
|
private $body; |
28
|
|
|
|
29
|
|
|
public function __construct(string $sender, string $title, string $body) |
30
|
|
|
{ |
31
|
|
|
$this->construct($sender, $title, $body); |
32
|
|
|
|
33
|
|
|
$this->sender = $sender; |
34
|
|
|
$this->title = $title; |
35
|
|
|
$this->body = $body; |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
final class SMS extends Notification |
40
|
|
|
{ |
41
|
|
|
use Deconstruction; |
42
|
|
|
|
43
|
|
|
private $caller; |
44
|
|
|
private $message; |
45
|
|
|
|
46
|
|
|
public function __construct(string $caller, string $message) |
47
|
|
|
{ |
48
|
|
|
$this->construct($caller, $message); |
49
|
|
|
|
50
|
|
|
$this->caller = $caller; |
51
|
|
|
$this->message = $message; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
final class VoiceRecording extends Notification |
56
|
|
|
{ |
57
|
|
|
use Deconstruction; |
58
|
|
|
|
59
|
|
|
private $contactName; |
60
|
|
|
private $link; |
61
|
|
|
|
62
|
|
|
public function __construct(string $contactName, string $link) |
63
|
|
|
{ |
64
|
|
|
$this->construct($contactName, $link); |
65
|
|
|
|
66
|
|
|
$this->contactName = $contactName; |
67
|
|
|
$this->link = $link; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
function showNotification(Notification $notification): string |
72
|
|
|
{ |
73
|
|
|
return match($notification) |
74
|
|
|
->case( |
75
|
|
|
Type(Email::class, Type('string')->bind(), Type('string')->bind(), Any()), |
|
|
|
|
76
|
|
|
papply(concat, 'You got an email from ', __, 'with title: ', __) |
77
|
|
|
) |
78
|
|
|
->case( |
79
|
|
|
Type(SMS::class, Type('string')->bind(), Type('string')->bind()), |
|
|
|
|
80
|
|
|
papply(concat, 'You got an SMS from ', __, '! Message: ', __) |
81
|
|
|
) |
82
|
|
|
->case( |
83
|
|
|
Type(VoiceRecording::class, Type('string')->bind(), Type('string')->bind()), |
84
|
|
|
papply(concat, 'You received a Voice Recording from ', __, '! Click the link to hear it: ', __) |
85
|
|
|
) |
86
|
|
|
->done(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
$someSms = new SMS('12345', 'Are you there?'); |
90
|
|
|
$someVoiceRecording = new VoiceRecording('Tom', 'voicerecording.org/id/123'); |
91
|
|
|
|
92
|
|
|
println(showNotification($someSms)); |
93
|
|
|
println(showNotification($someVoiceRecording)); |
94
|
|
|
|
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