Implement creator studio and upload updates
This commit is contained in:
30
app/Services/Images/Detectors/ChainedSubjectDetector.php
Normal file
30
app/Services/Images/Detectors/ChainedSubjectDetector.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Images\Detectors;
|
||||
|
||||
use App\Contracts\Images\SubjectDetectorInterface;
|
||||
use App\Data\Images\SubjectDetectionResultData;
|
||||
|
||||
final class ChainedSubjectDetector implements SubjectDetectorInterface
|
||||
{
|
||||
/**
|
||||
* @param iterable<int, SubjectDetectorInterface> $detectors
|
||||
*/
|
||||
public function __construct(private readonly iterable $detectors)
|
||||
{
|
||||
}
|
||||
|
||||
public function detect(string $sourcePath, int $sourceWidth, int $sourceHeight, array $context = []): ?SubjectDetectionResultData
|
||||
{
|
||||
foreach ($this->detectors as $detector) {
|
||||
$result = $detector->detect($sourcePath, $sourceWidth, $sourceHeight, $context);
|
||||
if ($result !== null) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user