-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for handling blobs via arrays
- Loading branch information
1 parent
c526b17
commit 146770c
Showing
6 changed files
with
79 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Atproto\DataModel\Blob; | ||
|
||
use Atproto\Contracts\DataModel\BlobHandler; | ||
use Atproto\Support\Arr; | ||
|
||
class ArrayBlobHandler implements BlobHandler | ||
{ | ||
private array $blob; | ||
|
||
public function __construct(array $blob) | ||
{ | ||
$this->blob = $blob; | ||
} | ||
|
||
public function size(): int | ||
{ | ||
return Arr::get($this->blob, 'size'); | ||
} | ||
|
||
public function mimeType(): string | ||
{ | ||
return Arr::get($this->blob, 'mimeType'); | ||
} | ||
|
||
public function content(): string | ||
{ | ||
throw new \LogicException("Content does not exists for array blob handler."); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return Arr::get($this->blob, 'ref.$link'); | ||
} | ||
} |
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