-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows cache data between tasks while processing `File`.
- Loading branch information
Showing
18 changed files
with
492 additions
and
52 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
19 changes: 19 additions & 0 deletions
19
packages/documentator/src/Processor/Contracts/Metadata.php
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,19 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Documentator\Processor\Contracts; | ||
|
||
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; | ||
|
||
/** | ||
* @template TValue | ||
*/ | ||
interface Metadata { | ||
/** | ||
* Resolves the metadata. | ||
* | ||
* The method should not be called directly, use {@see File::getMetadata()}. | ||
* | ||
* @return TValue | ||
*/ | ||
public function __invoke(File $file): mixed; | ||
} |
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
34 changes: 34 additions & 0 deletions
34
packages/documentator/src/Processor/Exceptions/FileMetadataError.php
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,34 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Documentator\Processor\Exceptions; | ||
|
||
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Metadata; | ||
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; | ||
use Throwable; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class FileMetadataError extends MetadataError { | ||
public function __construct( | ||
protected readonly File $target, | ||
/** | ||
* @var Metadata<*> | ||
*/ | ||
protected readonly Metadata $metadata, | ||
Throwable $previous, | ||
) { | ||
parent::__construct('', $previous); | ||
} | ||
|
||
public function getTarget(): File { | ||
return $this->target; | ||
} | ||
|
||
/** | ||
* @return Metadata<*> | ||
*/ | ||
public function getMetadata(): Metadata { | ||
return $this->metadata; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/documentator/src/Processor/Exceptions/FileMetadataFailed.php
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,47 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Documentator\Processor\Exceptions; | ||
|
||
use LastDragon_ru\LaraASP\Documentator\Processor\Contracts\Metadata; | ||
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\Directory; | ||
use LastDragon_ru\LaraASP\Documentator\Processor\FileSystem\File; | ||
use Throwable; | ||
|
||
use function sprintf; | ||
|
||
class FileMetadataFailed extends MetadataError { | ||
public function __construct( | ||
protected Directory $root, | ||
protected readonly File $target, | ||
/** | ||
* @var Metadata<*> | ||
*/ | ||
protected readonly Metadata $metadata, | ||
?Throwable $previous = null, | ||
) { | ||
parent::__construct( | ||
sprintf( | ||
'Failed to retrieve `%s` metadata for `%s` file (root: `%s`).', | ||
$this->metadata::class, | ||
$this->target->getRelativePath($this->root), | ||
$this->root->getPath(), | ||
), | ||
$previous, | ||
); | ||
} | ||
|
||
public function getRoot(): Directory { | ||
return $this->root; | ||
} | ||
|
||
public function getTarget(): File { | ||
return $this->target; | ||
} | ||
|
||
/** | ||
* @return Metadata<*> | ||
*/ | ||
public function getMetadata(): Metadata { | ||
return $this->metadata; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/documentator/src/Processor/Exceptions/MetadataError.php
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,7 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace LastDragon_ru\LaraASP\Documentator\Processor\Exceptions; | ||
|
||
abstract class MetadataError extends ProcessorError { | ||
// empty | ||
} |
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
Oops, something went wrong.