diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/src/ncc/Objects/ProjectConfiguration.php b/src/ncc/Objects/ProjectConfiguration.php index 416001f..3f80114 100644 --- a/src/ncc/Objects/ProjectConfiguration.php +++ b/src/ncc/Objects/ProjectConfiguration.php @@ -36,7 +36,9 @@ */ public function __construct() { + $this->Project = new Project(); $this->Assembly = new Assembly(); + $this->Build = new Build(); } /** @@ -63,7 +65,9 @@ public function toArray(bool $bytecode=false): array { return [ - ($bytecode ? Functions::cbc('assembly') : 'assembly') => $this->Assembly->toArray($bytecode) + ($bytecode ? Functions::cbc('project') : 'project') => $this->Project->toArray($bytecode), + ($bytecode ? Functions::cbc('assembly') : 'assembly') => $this->Assembly->toArray($bytecode), + ($bytecode ? Functions::cbc('build') : 'build') => $this->Build->toArray($bytecode), ]; } diff --git a/src/ncc/Objects/ProjectConfiguration/Build.php b/src/ncc/Objects/ProjectConfiguration/Build.php index b695756..a0fd70a 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build.php +++ b/src/ncc/Objects/ProjectConfiguration/Build.php @@ -1,5 +1,7 @@ Name; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('options') : 'options')] = $this->Options; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('static_linking') : 'static_linking')] = $this->StaticLinking; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('output_path') : 'output_path')] = $this->OutputPath; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('define_constants') : 'define_constants')] = $this->DefineConstants; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('strict_constants') : 'strict_constants')] = $this->StrictConstants; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('exclude_files') : 'exclude_files')] = $this->ExcludeFiles; - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('dependencies') : 'dependencies')] = []; + $ReturnResults[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name; + $ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options; + $ReturnResults[($bytecode ? Functions::cbc('static_linking') : 'static_linking')] = $this->StaticLinking; + $ReturnResults[($bytecode ? Functions::cbc('output_path') : 'output_path')] = $this->OutputPath; + $ReturnResults[($bytecode ? Functions::cbc('define_constants') : 'define_constants')] = $this->DefineConstants; + $ReturnResults[($bytecode ? Functions::cbc('strict_constants') : 'strict_constants')] = $this->StrictConstants; + $ReturnResults[($bytecode ? Functions::cbc('exclude_files') : 'exclude_files')] = $this->ExcludeFiles; + $ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')] = []; foreach($this->Dependencies as $dependency) { - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('dependencies') : 'dependencies')][] = $dependency->toArray(); + $ReturnResults[($bytecode ? Functions::cbc('dependencies') : 'dependencies')][] = $dependency->toArray(); } return $ReturnResults; @@ -114,44 +118,47 @@ { $BuildConfigurationObject = new BuildConfiguration(); - if(\ncc\Utilities\Functions::array_bc($data, 'name') !== null) + if(Functions::array_bc($data, 'name') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'name'); + $BuildConfigurationObject->Name = Functions::array_bc($data, 'name'); } - if(\ncc\Utilities\Functions::array_bc($data, 'options') !== null) + if(Functions::array_bc($data, 'options') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'options'); + $BuildConfigurationObject->Options = Functions::array_bc($data, 'options'); } - if(\ncc\Utilities\Functions::array_bc($data, 'static_linking') !== null) + if(Functions::array_bc($data, 'static_linking') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'static_linking'); + $BuildConfigurationObject->StaticLinking = Functions::array_bc($data, 'static_linking'); } - if(\ncc\Utilities\Functions::array_bc($data, 'output_path') !== null) + if(Functions::array_bc($data, 'output_path') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'output_path'); + $BuildConfigurationObject->OutputPath = Functions::array_bc($data, 'output_path'); } - if(\ncc\Utilities\Functions::array_bc($data, 'define_constants') !== null) + if(Functions::array_bc($data, 'define_constants') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'define_constants'); + $BuildConfigurationObject->DefineConstants = Functions::array_bc($data, 'define_constants'); } - if(\ncc\Utilities\Functions::array_bc($data, 'strict_constants') !== null) + if(Functions::array_bc($data, 'strict_constants') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'strict_constants'); + $BuildConfigurationObject->StrictConstants = Functions::array_bc($data, 'strict_constants'); } - if(\ncc\Utilities\Functions::array_bc($data, 'exclude_files') !== null) + if(Functions::array_bc($data, 'exclude_files') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'exclude_files'); + $BuildConfigurationObject->ExcludeFiles = Functions::array_bc($data, 'exclude_files'); } - if(\ncc\Utilities\Functions::array_bc($data, 'dependencies') !== null) + if(Functions::array_bc($data, 'dependencies') !== null) { - $BuildConfigurationObject = \ncc\Utilities\Functions::array_bc($data, 'dependencies'); + foreach(Functions::array_bc($data, 'dependencies') as $item) + { + $BuildConfigurationObject->Dependencies[] = Dependency::fromArray($item); + } } return $BuildConfigurationObject; diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index be335a3..0bd9948 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -1,8 +1,74 @@ $this->Extension, + ($bytecode ? Functions::cbc('minimum_version') : 'minimum_version') => $this->MinimumVersion, + ($bytecode ? Functions::cbc('maximum_version') : 'maximum_version') => $this->MaximumVersion + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return Compiler + */ + public static function fromArray(array $data): Compiler + { + $CompilerObject = new Compiler(); + + if(Functions::array_bc($data, 'extension') !== null) + { + $CompilerObject->Extension = Functions::array_bc($data, 'extension'); + } + + if(Functions::array_bc($data, 'maximum_version') !== null) + { + $CompilerObject->MaximumVersion = Functions::array_bc($data, 'maximum_version'); + } + + if(Functions::array_bc($data, 'minimum_version') !== null) + { + $CompilerObject->MinimumVersion = Functions::array_bc($data, 'minimum_version'); + } + + return $CompilerObject; + } + } \ No newline at end of file diff --git a/src/ncc/Objects/ProjectConfiguration/Dependency.php b/src/ncc/Objects/ProjectConfiguration/Dependency.php index 7e552d5..7ca34e9 100644 --- a/src/ncc/Objects/ProjectConfiguration/Dependency.php +++ b/src/ncc/Objects/ProjectConfiguration/Dependency.php @@ -1,7 +1,11 @@ Name; + $ReturnResults[($bytecode ? Functions::cbc('name') : 'name')] = $this->Name; if($this->Source !== null && strlen($this->Source) > 0) { - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('source') : 'source')] = $this->Source; + $ReturnResults[($bytecode ? Functions::cbc('source') : 'source')] = $this->Source; } if($this->Version !== null && strlen($this->Version) > 0) { - $ReturnResults[($bytecode ? \ncc\Utilities\Functions::cbc('version') : 'version')] = $this->Version; + $ReturnResults[($bytecode ? Functions::cbc('version') : 'version')] = $this->Version; } return $ReturnResults; @@ -61,9 +66,9 @@ { $DependencyObject = new Dependency(); - $DependencyObject->Name = \ncc\Utilities\Functions::array_bc($data, 'name'); - $DependencyObject->Source = \ncc\Utilities\Functions::array_bc($data, 'source'); - $DependencyObject->Version = \ncc\Utilities\Functions::array_bc($data, 'version'); + $DependencyObject->Name = Functions::array_bc($data, 'name'); + $DependencyObject->Source = Functions::array_bc($data, 'source'); + $DependencyObject->Version = Functions::array_bc($data, 'version'); return $DependencyObject; } diff --git a/src/ncc/Objects/ProjectConfiguration/Project.php b/src/ncc/Objects/ProjectConfiguration/Project.php index 267af72..c7bac15 100644 --- a/src/ncc/Objects/ProjectConfiguration/Project.php +++ b/src/ncc/Objects/ProjectConfiguration/Project.php @@ -1,8 +1,68 @@ Compiler = new Compiler(); + $this->Options = []; + } + + /** + * Returns an array representation of the object + * + * @param bool $bytecode + * @return array + */ + public function toArray(bool $bytecode=false): array + { + $ReturnResults = []; + + $ReturnResults[($bytecode ? Functions::cbc('compiler') : 'compiler')] = $this->Compiler->toArray($bytecode); + $ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options; + + return $ReturnResults; + } + + /** + * Constructs the object from an array representation + * + * @param array $data + * @return Project + */ + public static function fromArray(array $data): Project + { + $ProjectObject = new Project(); + + if(Functions::array_bc($data, 'compiler') !== null) + { + $ProjectObject->Compiler = Compiler::fromArray(Functions::array_bc($data, 'compiler')); + } + + if(Functions::array_bc($data, 'options') !== null) + { + $ProjectObject->Options = Functions::array_bc($data, 'options'); + } + + return $ProjectObject; + } + } \ No newline at end of file diff --git a/src/ncc/autoload.php b/src/ncc/autoload.php new file mode 100644 index 0000000..e33bf1e --- /dev/null +++ b/src/ncc/autoload.php @@ -0,0 +1,33 @@ + '/Abstracts/ExceptionCodes.php', + 'ncc\\abstracts\\regexpatterns' => '/Abstracts/RegexPatterns.php', + 'ncc\\exceptions\\invalidprojectconfigurationexception' => '/Exceptions/InvalidProjectConfigurationException.php', + 'ncc\\ncc' => '/ncc.php', + 'ncc\\objects\\projectconfiguration' => '/Objects/ProjectConfiguration.php', + 'ncc\\objects\\projectconfiguration\\assembly' => '/Objects/ProjectConfiguration/Assembly.php', + 'ncc\\objects\\projectconfiguration\\build' => '/Objects/ProjectConfiguration/Build.php', + 'ncc\\objects\\projectconfiguration\\buildconfiguration' => '/Objects/ProjectConfiguration/BuildConfiguration.php', + 'ncc\\objects\\projectconfiguration\\compiler' => '/Objects/ProjectConfiguration/Compiler.php', + 'ncc\\objects\\projectconfiguration\\dependency' => '/Objects/ProjectConfiguration/Dependency.php', + 'ncc\\objects\\projectconfiguration\\project' => '/Objects/ProjectConfiguration/Project.php', + 'ncc\\utilities\\functions' => '/Utilities/Functions.php', + 'ncc\\utilities\\validate' => '/Utilities/Validate.php' + ); + } + $cn = strtolower($class); + if (isset($classes[$cn])) { + require __DIR__ . $classes[$cn]; + } + }, + true, + false +); +// @codeCoverageIgnoreEnd