-
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.
- Loading branch information
Showing
13 changed files
with
134 additions
and
26 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
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Revolution\Bluesky\Labeler; | ||
|
||
use Revolution\Bluesky\Core\CBOR\AtBytes; | ||
|
||
class SavedLabel extends SignedLabel | ||
{ | ||
public function __construct( | ||
public int $id, | ||
SignedLabel $signed, | ||
) { | ||
parent::__construct( | ||
$signed->toUnsigned(), | ||
$signed->sig, | ||
); | ||
} | ||
|
||
/** | ||
* @return array{id: int, uri: string, cid: ?string, val: string, src: string, cts: string, exp: ?string, sig: AtBytes} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return get_object_vars($this); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Revolution\Bluesky\Labeler; | ||
|
||
use Revolution\Bluesky\Core\CBOR\AtBytes; | ||
|
||
class SignedLabel extends UnsignedLabel | ||
{ | ||
public function __construct( | ||
UnsignedLabel $unsigned, | ||
public AtBytes $sig, | ||
) { | ||
parent::__construct( | ||
...$unsigned->toArray(), | ||
); | ||
} | ||
|
||
public function toUnsigned(): UnsignedLabel | ||
{ | ||
return new UnsignedLabel($this->uri, $this->cid, $this->val, $this->src, $this->cts, $this->exp); | ||
} | ||
|
||
/** | ||
* @return array{uri: string, cid: ?string, val: string, src: string, cts: string, exp: ?string, sig: AtBytes} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return get_object_vars($this); | ||
} | ||
} |
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 Revolution\Bluesky\Labeler; | ||
|
||
use Illuminate\Contracts\Support\Arrayable; | ||
use Revolution\Bluesky\Core\CBOR\AtBytes; | ||
|
||
class UnsignedLabel implements Arrayable | ||
{ | ||
public function __construct( | ||
public string $uri, | ||
public ?string $cid, | ||
public string $val, | ||
public string $src, | ||
public string $cts, | ||
public ?string $exp, | ||
) { | ||
} | ||
|
||
public function toSigned(string|AtBytes $sig): SignedLabel | ||
{ | ||
if (is_string($sig)) { | ||
$sig = new AtBytes($sig); | ||
} | ||
|
||
return new SignedLabel($this, $sig); | ||
} | ||
|
||
/** | ||
* @return array{uri: string, cid: ?string, val: string, src: string, cts: string, exp: ?string} | ||
*/ | ||
public function toArray(): array | ||
{ | ||
return get_object_vars($this); | ||
} | ||
} |
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