Skip to content

Commit 39391bb

Browse files
committed
add internal Watch\Implementation
1 parent 780f8af commit 39391bb

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

src/Watch.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Innmind\FileWatch;
55

66
use Innmind\FileWatch\Watch\{
7+
Implementation,
78
Kind,
89
Logger,
910
Fallback,
@@ -19,7 +20,7 @@
1920
final class Watch
2021
{
2122
private function __construct(
22-
private Kind|Logger $implementation,
23+
private Implementation $implementation,
2324
) {
2425
}
2526

src/Watch/Implementation.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
}

src/Watch/Kind.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
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()) {

src/Watch/Logger.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
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
}

0 commit comments

Comments
 (0)