From 55d44d86077e8512c15389f9b2f9c9157b4a3137 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 12 May 2026 04:34:12 +0900 Subject: feat(port): port ForgejoRepositoryData.php --- crates/shirabe-php-shim/src/lib.rs | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'crates/shirabe-php-shim') 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>), } +impl PhpMixed { + pub fn as_bool(&self) -> Option { + match self { + PhpMixed::Bool(b) => Some(*b), + _ => None, + } + } + + pub fn as_int(&self) -> Option { + match self { + PhpMixed::Int(i) => Some(*i), + _ => None, + } + } + + pub fn as_float(&self) -> Option { + 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>> { + match self { + PhpMixed::List(l) => Some(l), + _ => None, + } + } + + pub fn as_array(&self) -> Option<&IndexMap>> { + 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, -- cgit v1.3.1