From 954cf0fd119b3998cb376d8721d38f0a127ed573 Mon Sep 17 00:00:00 2001 From: Zi Xing Date: Sat, 16 Apr 2022 17:57:34 -0400 Subject: [PATCH] Updated \ncc\Objects\ProjectConfiguration > Build --- .../Objects/ProjectConfiguration/Build.php | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/ncc/Objects/ProjectConfiguration/Build.php b/src/ncc/Objects/ProjectConfiguration/Build.php index a0fd70a..dfa4dea 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build.php +++ b/src/ncc/Objects/ProjectConfiguration/Build.php @@ -4,6 +4,8 @@ namespace ncc\Objects\ProjectConfiguration; + use ncc\Utilities\Functions; + class Build { /** @@ -62,6 +64,18 @@ */ public $Configurations; + /** + * Public Constructor + */ + public function __construct() + { + $this->ExcludeFiles = []; + $this->Options = []; + $this->DefineConstants = []; + $this->Dependencies = []; + $this->Configurations = []; + } + /** * Returns an array representation of the object * @@ -70,6 +84,64 @@ */ public function toArray(bool $bytecode=false): array { + $ReturnResults = []; + $ReturnResults[($bytecode ? Functions::cbc('source_path') : 'source_path')] = $this->SourcePath; + $ReturnResults[($bytecode ? Functions::cbc('default_configuration') : 'default_configuration')] = $this->DefaultConfiguration; + $ReturnResults[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->ExcludeFiles; + $ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options; + $ReturnResults[($bytecode ? Functions::cbc('scope') : 'scope')] = $this->Scope; + $ReturnResults[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->DefineConstants; + $ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = []; + + foreach($this->Dependencies as $dependency) + { + $ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')][] = $dependency->toArray($bytecode); + } + + $ReturnResults[($bytecode ? Functions::cbc('configurations') : 'configurations')] = []; + + foreach($this->Configurations as $configuration) + { + $ReturnResults[($bytecode ? Functions::cbc('configurations') : 'configurations')][] = $configuration->toArray($bytecode); + } + + return $ReturnResults; + } + + /** + * Returns an array + * + * @param array $data + * @return Build + */ + public static function fromArray(array $data): Build + { + $BuildObject = new Build(); + + $BuildObject->SourcePath = Functions::array_bc($data, 'source_path'); + $BuildObject->DefaultConfiguration = Functions::array_bc($data, 'default_configuration'); + $BuildObject->ExcludeFiles = (Functions::array_bc($data, 'exclude_files') ?? []); + $BuildObject->Options = (Functions::array_bc($data, 'options') ?? []); + $BuildObject->Scope = Functions::array_bc($data, 'scope'); + $BuildObject->DefineConstants = (Functions::array_bc($data, 'define_constants') ?? []); + + if(Functions::array_bc($data, 'dependencies') !== null) + { + foreach(Functions::array_bc($data, 'dependencies') as $dependency) + { + $BuildObject->Dependencies[] = Dependency::fromArray($dependency); + } + } + + if(Functions::array_bc($data, 'configurations') !== null) + { + foreach(Functions::array_bc($data, 'configurations') as $configuration) + { + $BuildObject->Configurations[] = BuildConfiguration::fromArray($configuration); + } + } + + return $BuildObject; } } \ No newline at end of file