File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44namespace Innmind \FileWatch ;
55
66use Innmind \FileWatch \Watch \{
7+ Implementation ,
78 Kind ,
89 Logger ,
910 Fallback ,
1920final class Watch
2021{
2122 private function __construct (
22- private Kind | Logger $ implementation ,
23+ private Implementation $ implementation ,
2324 ) {
2425 }
2526
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types = 1 );
3+
4+ namespace Innmind \FileWatch \Watch ;
5+
6+ use Innmind \FileWatch \Ping ;
7+ use Innmind \Url \Path ;
8+
9+ /**
10+ * @internal
11+ */
12+ interface Implementation
13+ {
14+ public function __invoke (Path $ file ): Ping \Implementation ;
15+ }
Original file line number Diff line number Diff line change 99/**
1010 * @internal
1111 */
12- final class Kind
12+ final class Kind implements Implementation
1313{
1414 public function __construct (
1515 private Fallback $ files ,
1616 private Stat $ directories ,
1717 ) {
1818 }
1919
20+ #[\Override]
2021 public function __invoke (Path $ file ): Ping \Implementation
2122 {
2223 return match ($ file ->directory ()) {
Original file line number Diff line number Diff line change 1010/**
1111 * @internal
1212 */
13- final class Logger
13+ final class Logger implements Implementation
1414{
1515 private function __construct (
16- private Kind $ watch ,
16+ private Implementation $ watch ,
1717 private LoggerInterface $ logger ,
1818 ) {
1919 }
2020
21+ #[\Override]
2122 public function __invoke (Path $ path ): Ping \Implementation
2223 {
2324 return Ping \Logger::psr (
@@ -27,17 +28,8 @@ public function __invoke(Path $path): Ping\Implementation
2728 );
2829 }
2930
30- public static function psr (Kind | self $ watch , LoggerInterface $ logger ): self
31+ public static function psr (Implementation $ watch , LoggerInterface $ logger ): self
3132 {
32- return new self (self ::extract ($ watch ), $ logger );
33- }
34-
35- private static function extract (Kind |self $ watch ): Kind
36- {
37- if ($ watch instanceof Kind) {
38- return $ watch ;
39- }
40-
41- return self ::extract ($ watch ->watch );
33+ return new self ($ watch , $ logger );
4234 }
4335}
You can’t perform that action at this time.
0 commit comments