//! ref: composer/src/Composer/Package/CompletePackage.php use crate::package::CompletePackageInterface; use crate::package::Package; use crate::package::PackageInterface; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; #[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 CompletePackage { pub fn new(name: String, version: String, pretty_version: String) -> Self { Self { inner: crate::package::Package::new(name, version, pretty_version), repositories: Vec::new(), license: Vec::new(), keywords: Vec::new(), authors: Vec::new(), description: None, homepage: None, scripts: IndexMap::new(), support: IndexMap::new(), funding: Vec::new(), abandoned: PhpMixed::Bool(false), archive_name: None, archive_excludes: Vec::new(), } } } 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() } } impl PackageInterface for CompletePackage { fn get_name(&self) -> &str { todo!() } fn get_pretty_name(&self) -> &str { todo!() } fn get_names(&self, provides: bool) -> Vec { todo!() } fn set_id(&mut self, id: i64) { todo!() } fn get_id(&self) -> i64 { todo!() } fn is_dev(&self) -> bool { todo!() } fn get_type(&self) -> &str { todo!() } fn get_target_dir(&self) -> Option<&str> { todo!() } fn get_extra(&self) -> IndexMap { todo!() } fn set_installation_source(&mut self, r#type: Option) { todo!() } fn get_installation_source(&self) -> Option<&str> { todo!() } fn get_source_type(&self) -> Option<&str> { todo!() } fn get_source_url(&self) -> Option<&str> { todo!() } fn get_source_urls(&self) -> Vec { todo!() } fn get_source_reference(&self) -> Option<&str> { todo!() } fn get_source_mirrors(&self) -> Option>> { todo!() } fn set_source_mirrors(&mut self, mirrors: Option>>) { todo!() } fn get_dist_type(&self) -> Option<&str> { todo!() } fn get_dist_url(&self) -> Option<&str> { todo!() } fn get_dist_urls(&self) -> Vec { todo!() } fn get_dist_reference(&self) -> Option<&str> { todo!() } fn get_dist_sha1_checksum(&self) -> Option<&str> { todo!() } fn get_dist_mirrors(&self) -> Option>> { todo!() } fn set_dist_mirrors(&mut self, mirrors: Option>>) { todo!() } fn get_version(&self) -> &str { todo!() } fn get_pretty_version(&self) -> &str { todo!() } fn get_full_pretty_version(&self, truncate: bool, display_mode: i64) -> String { todo!() } fn get_release_date(&self) -> Option> { todo!() } fn get_stability(&self) -> &str { todo!() } fn get_requires(&self) -> IndexMap { todo!() } fn get_conflicts(&self) -> IndexMap { todo!() } fn get_provides(&self) -> IndexMap { todo!() } fn get_replaces(&self) -> IndexMap { todo!() } fn get_dev_requires(&self) -> IndexMap { todo!() } fn get_suggests(&self) -> IndexMap { todo!() } fn get_autoload(&self) -> IndexMap { todo!() } fn get_dev_autoload(&self) -> IndexMap { todo!() } fn get_include_paths(&self) -> Vec { todo!() } fn get_php_ext(&self) -> Option> { todo!() } fn set_repository( &mut self, repository: crate::repository::RepositoryInterfaceHandle, ) -> anyhow::Result<()> { self.inner.set_repository(repository) } fn get_repository(&self) -> Option { self.inner.get_repository() } fn get_binaries(&self) -> Vec { todo!() } fn get_unique_name(&self) -> String { todo!() } fn get_notification_url(&self) -> Option<&str> { todo!() } fn get_pretty_string(&self) -> String { todo!() } fn is_default_branch(&self) -> bool { todo!() } fn get_transport_options(&self) -> IndexMap { todo!() } fn set_transport_options(&mut self, options: IndexMap) { todo!() } fn set_source_reference(&mut self, reference: Option) { todo!() } fn set_dist_url(&mut self, url: Option) { todo!() } fn set_dist_type(&mut self, r#type: Option) { todo!() } fn set_dist_reference(&mut self, reference: Option) { todo!() } fn set_source_dist_references(&mut self, reference: &str) { todo!() } } impl std::fmt::Display for CompletePackage { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.get_unique_name()) } }