Skip to content

Commit

Permalink
Create Identity.php
Browse files Browse the repository at this point in the history
  • Loading branch information
kawax committed Oct 14, 2024
1 parent 7bb8aa4 commit 5eba858
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Support/Identity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Revolution\Bluesky\Support;

class Identity
{
protected const HANDLE_REGEX = '/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/';

protected const DID_REGEX = '/^did:[a-z]+:[a-zA-Z0-9._:%-]*[a-zA-Z0-9._-]$/';

public static function isHandle(string $handle): bool
{
return preg_match(self::HANDLE_REGEX, $handle) === 1;
}

public static function isDID(string $did): bool
{
return preg_match(self::DID_REGEX, $did) === 1;
}
}

0 comments on commit 5eba858

Please sign in to comment.