diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4217dec --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/ncc.iml b/.idea/ncc.iml new file mode 100644 index 0000000..77098d0 --- /dev/null +++ b/.idea/ncc.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/webResources.xml b/.idea/webResources.xml new file mode 100644 index 0000000..0da97ec --- /dev/null +++ b/.idea/webResources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/specifications/.~lock.byte_table.ods# b/docs/specifications/.~lock.byte_table.ods# new file mode 100644 index 0000000..302ffe6 --- /dev/null +++ b/docs/specifications/.~lock.byte_table.ods# @@ -0,0 +1 @@ +,netkas,netkas-desktop,06.04.2022 21:07,file:///home/netkas/.config/libreoffice/4; \ No newline at end of file diff --git a/docs/specifications/byte_table.ods b/docs/specifications/byte_table.ods new file mode 100644 index 0000000..5118235 Binary files /dev/null and b/docs/specifications/byte_table.ods differ diff --git a/src/ncc/Abstracts/ExceptionCodes.php b/src/ncc/Abstracts/ExceptionCodes.php new file mode 100644 index 0000000..4cff00c --- /dev/null +++ b/src/ncc/Abstracts/ExceptionCodes.php @@ -0,0 +1,13 @@ +0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/m'; + } \ No newline at end of file diff --git a/src/ncc/Exceptions/InvalidProjectConfigurationException.php b/src/ncc/Exceptions/InvalidProjectConfigurationException.php new file mode 100644 index 0000000..5a0372f --- /dev/null +++ b/src/ncc/Exceptions/InvalidProjectConfigurationException.php @@ -0,0 +1,36 @@ +message = $message; + $this->previous = $previous; + $this->property = $property; + } + } \ No newline at end of file diff --git a/src/ncc/Objects/ProjectConfiguration.php b/src/ncc/Objects/ProjectConfiguration.php new file mode 100644 index 0000000..68ee448 --- /dev/null +++ b/src/ncc/Objects/ProjectConfiguration.php @@ -0,0 +1,54 @@ +UUID) == false) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The UUID is not a valid v4 UUID', 'Assembly.UUID'); + + return false; + } + + if(Validate::version($this->Version) == false) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The version number is invalid', 'Assembly.Version'); + + return false; + } + + if(preg_match(RegexPatterns::PackageNameFormat, $this->Package) == false) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The package name is invalid', 'Assembly.Package'); + + return false; + } + + if(strlen($this->Name) > 40) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The name cannot be larger than 40 characters', 'Assembly.Name'); + + return false; + } + + if(strlen($this->Description) > 512) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The description cannot be larger than 512 characters', 'Assembly.Description'); + + return false; + } + + if(strlen($this->Company) > 126) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The company cannot be larger than 126 characters', 'Assembly.Company'); + + return false; + } + + if(strlen($this->Product) > 64) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The company cannot be larger than 64 characters', 'Assembly.Product'); + + return false; + } + + if(strlen($this->Copyright) > 64) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The copyright cannot be larger than 64 characters', 'Assembly.Copyright'); + + return false; + } + + if(strlen($this->Trademark) > 64) + { + if($throw_exception) + throw new InvalidProjectConfigurationException('The trademark cannot be larger than 64 characters', 'Assembly.Trademark'); + + return false; + } + + return true; + } + + /** + * Returns an array representation of the object + * + * @param bool $bytecode + * @return array + */ + public function toArray(bool $bytecode=false): array + { + return [ + ($bytecode ? Functions::cbc('name') : 'name') => $this->Name, + ($bytecode ? Functions::cbc('package') : 'package') => $this->Package, + ($bytecode ? Functions::cbc('description') : 'description') => ($this->Description !== null && strlen($this->Description) > 0 ? $this->Description : null), + ($bytecode ? Functions::cbc('company') : 'company') => ($this->Company !== null && strlen($this->Company) > 0 ? $this->Company : null), + ($bytecode ? Functions::cbc('product') : 'product') => ($this->Product !== null && strlen($this->Product) > 0 ? $this->Product : null), + ($bytecode ? Functions::cbc('copyright') : 'copyright') => ($this->Copyright !== null && strlen($this->Copyright) > 0 ? $this->Copyright : null), + ($bytecode ? Functions::cbc('trademark') : 'trademark') => ($this->Trademark !== null && strlen($this->Trademark) > 0 ? $this->Trademark : null), + ($bytecode ? Functions::cbc('version') : 'version') => $this->Version, + ($bytecode ? Functions::cbc('uid') : 'uid') => $this->UUID, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return Assembly + */ + public static function fromArray(array $data): Assembly + { + $AssemblyObject = new Assembly(); + + $AssemblyObject->Name = Functions::array_bc($data, 'name'); + $AssemblyObject->Package = Functions::array_bc($data, 'package'); + $AssemblyObject->Description = Functions::array_bc($data, 'description'); + $AssemblyObject->Company = Functions::array_bc($data, 'company'); + $AssemblyObject->Product = Functions::array_bc($data, 'product'); + $AssemblyObject->Copyright = Functions::array_bc($data, 'copyright'); + $AssemblyObject->Trademark = Functions::array_bc($data, 'trademark'); + $AssemblyObject->Version = Functions::array_bc($data, 'version'); + $AssemblyObject->UUID = Functions::array_bc($data, 'uid'); + + return $AssemblyObject; + } + } \ No newline at end of file diff --git a/src/ncc/Objects/ProjectConfiguration/Build.php b/src/ncc/Objects/ProjectConfiguration/Build.php new file mode 100644 index 0000000..4a6d646 --- /dev/null +++ b/src/ncc/Objects/ProjectConfiguration/Build.php @@ -0,0 +1,8 @@ +