//! ref: composer/src/Composer/Package/CompletePackage.php use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; use crate::package::complete_package_interface::CompletePackageInterface; use crate::package::package::Package; #[derive(Debug)] pub struct CompletePackage { pub(crate) inner: Package, pub(crate) repositories: Vec>, pub(crate) license: Vec, pub(crate) keywords: Vec, pub(crate) authors: Vec>, pub(crate) description: Option, pub(crate) homepage: Option, pub(crate) scripts: IndexMap>, pub(crate) support: IndexMap, pub(crate) funding: Vec>, pub(crate) abandoned: PhpMixed, pub(crate) archive_name: Option, pub(crate) archive_excludes: Vec, } impl CompletePackageInterface for CompletePackage { fn set_scripts(&mut self, scripts: IndexMap>) { self.scripts = scripts; } fn get_scripts(&self) -> IndexMap> { self.scripts.clone() } fn set_repositories(&mut self, repositories: Vec>) { self.repositories = repositories; } fn get_repositories(&self) -> Vec> { self.repositories.clone() } fn set_license(&mut self, license: Vec) { self.license = license; } fn get_license(&self) -> Vec { self.license.clone() } fn set_keywords(&mut self, keywords: Vec) { self.keywords = keywords; } fn get_keywords(&self) -> Vec { self.keywords.clone() } fn set_authors(&mut self, authors: Vec>) { self.authors = authors; } fn get_authors(&self) -> Vec> { self.authors.clone() } fn set_description(&mut self, description: String) { self.description = Some(description); } fn get_description(&self) -> Option<&str> { self.description.as_deref() } fn set_homepage(&mut self, homepage: String) { self.homepage = Some(homepage); } fn get_homepage(&self) -> Option<&str> { self.homepage.as_deref() } fn set_support(&mut self, support: IndexMap) { self.support = support; } fn get_support(&self) -> IndexMap { self.support.clone() } fn set_funding(&mut self, funding: Vec>) { self.funding = funding; } fn get_funding(&self) -> Vec> { self.funding.clone() } fn is_abandoned(&self) -> bool { match &self.abandoned { PhpMixed::Bool(b) => *b, PhpMixed::String(s) => !s.is_empty(), _ => false, } } fn set_abandoned(&mut self, abandoned: PhpMixed) { self.abandoned = abandoned; } fn get_replacement_package(&self) -> Option<&str> { match &self.abandoned { PhpMixed::String(s) => Some(s.as_str()), _ => None, } } fn set_archive_name(&mut self, name: String) { self.archive_name = Some(name); } fn get_archive_name(&self) -> Option<&str> { self.archive_name.as_deref() } fn set_archive_excludes(&mut self, excludes: Vec) { self.archive_excludes = excludes; } fn get_archive_excludes(&self) -> Vec { self.archive_excludes.clone() } }