diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-12 04:34:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-12 04:38:06 +0900 |
| commit | 55d44d86077e8512c15389f9b2f9c9157b4a3137 (patch) | |
| tree | 2948b71fcd408a197635e6c61bd186c728cf9145 /crates/shirabe-php-shim | |
| parent | fbf8b80058669f258786a7d07c3467d5d09f2a4d (diff) | |
| download | php-shirabe-55d44d86077e8512c15389f9b2f9c9157b4a3137.tar.gz php-shirabe-55d44d86077e8512c15389f9b2f9c9157b4a3137.tar.zst php-shirabe-55d44d86077e8512c15389f9b2f9c9157b4a3137.zip | |
feat(port): port ForgejoRepositoryData.php
Diffstat (limited to 'crates/shirabe-php-shim')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index ef74970..35202ba 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -11,6 +11,54 @@ pub enum PhpMixed { Array(IndexMap<String, Box<PhpMixed>>), } +impl PhpMixed { + pub fn as_bool(&self) -> Option<bool> { + match self { + PhpMixed::Bool(b) => Some(*b), + _ => None, + } + } + + pub fn as_int(&self) -> Option<i64> { + match self { + PhpMixed::Int(i) => Some(*i), + _ => None, + } + } + + pub fn as_float(&self) -> Option<f64> { + match self { + PhpMixed::Float(f) => Some(*f), + _ => None, + } + } + + pub fn as_string(&self) -> Option<&str> { + match self { + PhpMixed::String(s) => Some(s.as_str()), + _ => None, + } + } + + pub fn as_list(&self) -> Option<&Vec<Box<PhpMixed>>> { + match self { + PhpMixed::List(l) => Some(l), + _ => None, + } + } + + pub fn as_array(&self) -> Option<&IndexMap<String, Box<PhpMixed>>> { + match self { + PhpMixed::Array(a) => Some(a), + _ => None, + } + } + + pub fn is_null(&self) -> bool { + matches!(self, PhpMixed::Null) + } +} + #[derive(Debug)] pub struct Exception { pub message: String, |
