-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add binary responder, including getCovertArt method
- Loading branch information
Showing
20 changed files
with
182 additions
and
23 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/FeatureSet/V1161/Contract/GetCoverArtDataProviderInterface.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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Usox\HyperSonic\FeatureSet\V1161\Contract; | ||
|
||
interface GetCoverArtDataProviderInterface extends V1161DataProviderInterface | ||
{ | ||
/** | ||
* @return array{ | ||
* contentType: string, | ||
* art: string | ||
* } | ||
*/ | ||
public function getArt(string $coverArtId): array; | ||
} |
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Usox\HyperSonic\FeatureSet\V1161\Method; | ||
|
||
use Usox\HyperSonic\FeatureSet\V1161\Contract\GetCoverArtDataProviderInterface; | ||
use Usox\HyperSonic\FeatureSet\V1161\Responder\ResponderFactoryInterface; | ||
use Usox\HyperSonic\Response\ResponderInterface; | ||
use Usox\HyperSonic\Response\ResponseWriterInterface; | ||
|
||
final class GetCoverArtMethod implements V1161MethodInterface | ||
{ | ||
public function __construct( | ||
private readonly ResponderFactoryInterface $responderFactory, | ||
) { | ||
} | ||
|
||
/** | ||
* @param array<string, scalar> $queryParams | ||
* @param array<string, scalar> $args | ||
*/ | ||
public function __invoke( | ||
ResponseWriterInterface $responseWriter, | ||
GetCoverArtDataProviderInterface $getCoverArtDataProvider, | ||
array $queryParams, | ||
array $args | ||
): ResponderInterface { | ||
$art = $getCoverArtDataProvider->getArt( | ||
(string) ($queryParams['id'] ?? '') | ||
); | ||
|
||
return $this->responderFactory->createCoverArtResponder( | ||
$art['art'], | ||
$art['contentType'], | ||
); | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Usox\HyperSonic\FeatureSet\V1161\Responder; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Usox\HyperSonic\Response\BinaryResponderInterface; | ||
|
||
final class CoverArtResponder implements BinaryResponderInterface | ||
{ | ||
public function __construct( | ||
private readonly string $covertArt, | ||
private readonly string $contentType, | ||
) { | ||
} | ||
|
||
public function isBinaryResponder(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function writeResponse(ResponseInterface $response): ResponseInterface | ||
{ | ||
$response->getBody()->write($this->covertArt); | ||
|
||
return $response->withHeader('Content-Type', $this->contentType); | ||
} | ||
} |
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
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Usox\HyperSonic\Response; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
|
||
interface BinaryResponderInterface extends ResponderInterface | ||
{ | ||
public function writeResponse(ResponseInterface $response): ResponseInterface; | ||
} |
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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Usox\HyperSonic\Response; | ||
|
||
use AaronDDM\XMLBuilder\XMLArray; | ||
|
||
interface FormattedResponderInterface extends ResponderInterface | ||
{ | ||
public function writeXml(XMLArray $XMLArray): void; | ||
|
||
/** | ||
* @param array<mixed, mixed> $root | ||
*/ | ||
public function writeJson(array &$root): void; | ||
} |
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