Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: add roave bc check replace eris by blackbox split jobs between coverage and full tests run send activity for all loaded files (even inside directories) only run 10 scenarii on dev environment use blackbox printer fix test
- Loading branch information
Showing
12 changed files
with
594 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Innmind\SilentCartographer\OperatingSystem\Filesystem; | ||
|
||
use Innmind\SilentCartographer\{ | ||
SendActivity, | ||
Room\Program\Activity\Filesystem\FileLoaded, | ||
}; | ||
use Innmind\Filesystem\{ | ||
Directory as DirectoryInterface, | ||
File as FileInterface, | ||
Name, | ||
}; | ||
use Innmind\Stream\Readable; | ||
use Innmind\MediaType\MediaType; | ||
use Innmind\Url\Path; | ||
use Innmind\Immutable\{ | ||
Sequence, | ||
Set, | ||
}; | ||
|
||
final class Directory implements DirectoryInterface | ||
{ | ||
private DirectoryInterface $directory; | ||
private SendActivity $send; | ||
private Path $path; | ||
|
||
private function __construct( | ||
DirectoryInterface $directory, | ||
SendActivity $send, | ||
Path $path | ||
) { | ||
$this->directory = $directory; | ||
$this->send = $send; | ||
$this->path = $path; | ||
} | ||
|
||
public static function load( | ||
DirectoryInterface $directory, | ||
SendActivity $send, | ||
Path $path | ||
): self { | ||
$self = new self($directory, $send, $path); | ||
$send(new FileLoaded($path)); | ||
|
||
return $self; | ||
} | ||
|
||
public function name(): Name | ||
{ | ||
return $this->directory->name(); | ||
} | ||
|
||
public function content(): Readable | ||
{ | ||
return $this->directory->content(); | ||
} | ||
|
||
public function mediaType(): MediaType | ||
{ | ||
return $this->directory->mediaType(); | ||
} | ||
|
||
public function add(FileInterface $file): DirectoryInterface | ||
{ | ||
return new self( | ||
$this->directory->add($file), | ||
$this->send, | ||
$this->path, | ||
); | ||
} | ||
|
||
public function get(Name $name): FileInterface | ||
{ | ||
return $this->wrap($this->directory->get($name)); | ||
} | ||
|
||
public function contains(Name $name): bool | ||
{ | ||
return $this->directory->contains($name); | ||
} | ||
|
||
public function remove(Name $name): DirectoryInterface | ||
{ | ||
$directory = $this->directory->remove($name); | ||
|
||
if ($directory === $this->directory) { | ||
return $this; | ||
} | ||
|
||
return new self( | ||
$this->directory->remove($name), | ||
$this->send, | ||
$this->path, | ||
); | ||
} | ||
|
||
public function replaceAt(Path $path, FileInterface $file): DirectoryInterface | ||
{ | ||
return new self( | ||
$this->directory->replaceAt($path, $file), | ||
$this->send, | ||
$this->path, | ||
); | ||
} | ||
|
||
public function foreach(callable $function): void | ||
{ | ||
$this->directory->foreach(function(FileInterface $file) use ($function): void { | ||
$function($this->wrap($file)); | ||
}); | ||
} | ||
|
||
public function filter(callable $predicate): Set | ||
{ | ||
return $this->directory->filter(function(FileInterface $file) use ($predicate): bool { | ||
return $predicate($this->wrap($file)); | ||
}); | ||
} | ||
|
||
public function reduce($carry, callable $reducer) | ||
{ | ||
/** @psalm-suppress MissingClosureParamType */ | ||
return $this->directory->reduce( | ||
$carry, | ||
function($carry, FileInterface $file) use ($reducer) { | ||
/** @psalm-suppress MixedArgument */ | ||
return $reducer($carry, $this->wrap($file)); | ||
}, | ||
); | ||
} | ||
|
||
public function modifications(): Sequence | ||
{ | ||
return $this->directory->modifications(); | ||
} | ||
|
||
private function wrap(FileInterface $file): FileInterface | ||
{ | ||
if ($file instanceof DirectoryInterface) { | ||
return new self( | ||
$file, | ||
$this->send, | ||
$this->path->resolve(Path::of($file->name()->toString().'/')), | ||
); | ||
} | ||
|
||
return new File($file, $this->send, $this->path); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Innmind\SilentCartographer\OperatingSystem\Filesystem; | ||
|
||
use Innmind\SilentCartographer\{ | ||
SendActivity, | ||
Room\Program\Activity\Filesystem\FileLoaded, | ||
}; | ||
use Innmind\Filesystem\{ | ||
File as FileInterface, | ||
Name, | ||
}; | ||
use Innmind\Stream\Readable; | ||
use Innmind\MediaType\MediaType; | ||
use Innmind\Url\Path; | ||
|
||
final class File implements FileInterface | ||
{ | ||
private FileInterface $file; | ||
|
||
public function __construct( | ||
FileInterface $file, | ||
SendActivity $send, | ||
Path $folder | ||
) { | ||
$this->file = $file; | ||
$send(new FileLoaded($folder->resolve(Path::of($file->name()->toString())))); | ||
} | ||
|
||
public function name(): Name | ||
{ | ||
return $this->file->name(); | ||
} | ||
|
||
public function content(): Readable | ||
{ | ||
return $this->file->content(); | ||
} | ||
|
||
public function mediaType(): MediaType | ||
{ | ||
return $this->file->mediaType(); | ||
} | ||
} |
Oops, something went wrong.