- Updated class \ncc\Objects\ProjectConfiguration > Project to use method calls rather than direct property access

- Updated class `\ncc\Objects\ProjectConfiguration > UpdateSource` to use method calls rather than direct property access
This commit is contained in:
Netkas 2023-08-27 11:41:11 -04:00
parent dc7fcfc757
commit 2ea1dfc27a
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
8 changed files with 129 additions and 28 deletions

View file

@ -135,6 +135,8 @@ features and reduced the number of exceptions down to 15 exceptions.
- Updated class `\ncc\Objects\ProjectConfiguration > Compiler` to use method calls rather than direct property access - Updated class `\ncc\Objects\ProjectConfiguration > Compiler` to use method calls rather than direct property access
- Updated class `\ncc\Objects\ProjectConfiguration > ExecutionPolicy` to use method calls rather than direct property access - Updated class `\ncc\Objects\ProjectConfiguration > ExecutionPolicy` to use method calls rather than direct property access
- Updated class `\ncc\Objects\ProjectConfiguration > Installer` to use method calls rather than direct property access - Updated class `\ncc\Objects\ProjectConfiguration > Installer` to use method calls rather than direct property access
- Updated class `\ncc\Objects\ProjectConfiguration > Project` to use method calls rather than direct property access
- Updated class `\ncc\Objects\ProjectConfiguration > UpdateSource` to use method calls rather than direct property access
### Removed ### Removed
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions` - Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`

View file

@ -336,9 +336,9 @@
$project_configuration->assembly->setPackage(self::toPackageName($composer_package->name)); $project_configuration->assembly->setPackage(self::toPackageName($composer_package->name));
// Add the update source // Add the update source
$project_configuration->project->update_source = new ProjectConfiguration\UpdateSource(); $project_configuration->project->setUpdateSource(new ProjectConfiguration\UpdateSource());
$project_configuration->project->update_source->source = sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->name)); $project_configuration->project->getUpdateSource()?->setSource(sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->name)));
$project_configuration->project->update_source->repository = null; $project_configuration->project->getUpdateSource()?->setRepository(null);
// Process the dependencies // Process the dependencies
if($composer_package->require !== null && count($composer_package->require) > 0) if($composer_package->require !== null && count($composer_package->require) > 0)
@ -373,9 +373,9 @@
$project_configuration->build->setSourcePath('.src'); $project_configuration->build->setSourcePath('.src');
// Apply a compiler extension // Apply a compiler extension
$project_configuration->project->compiler->setExtension(CompilerExtensions::PHP); $project_configuration->project->getCompiler()->setExtension(CompilerExtensions::PHP);
$project_configuration->project->compiler->setMaximumVersion(CompilerExtensionSupportedVersions::PHP[0]); $project_configuration->project->getCompiler()->setMaximumVersion(CompilerExtensionSupportedVersions::PHP[0]);
$project_configuration->project->compiler->setMinimumVersion(CompilerExtensionSupportedVersions::PHP[(count(CompilerExtensionSupportedVersions::PHP) - 1)]); $project_configuration->project->getCompiler()->setMinimumVersion(CompilerExtensionSupportedVersions::PHP[(count(CompilerExtensionSupportedVersions::PHP) - 1)]);
return $project_configuration; return $project_configuration;
} }
@ -758,7 +758,7 @@
if (count($static_files) > 0) if (count($static_files) > 0)
{ {
$project_configuration->project->options['static_files'] = $static_files; $project_configuration->project->addOption('static_files', $static_files);
foreach ($static_files as $file) foreach ($static_files as $file)
{ {

View file

@ -71,21 +71,21 @@
{ {
Console::outDebug(sprintf('assembly.%s: %s', $prop, ($value ?? 'n/a'))); Console::outDebug(sprintf('assembly.%s: %s', $prop, ($value ?? 'n/a')));
} }
foreach($configuration->project->compiler->toArray() as $prop => $value) foreach($configuration->project->getCompiler()->toArray() as $prop => $value)
{ {
Console::outDebug(sprintf('compiler.%s: %s', $prop, ($value ?? 'n/a'))); Console::outDebug(sprintf('compiler.%s: %s', $prop, ($value ?? 'n/a')));
} }
} }
// Select the correct compiler for the specified extension // Select the correct compiler for the specified extension
if (strtolower($configuration->project->compiler->getExtension()) === CompilerExtensions::PHP) if (strtolower($configuration->project->getCompiler()->getExtension()) === CompilerExtensions::PHP)
{ {
/** @var CompilerInterface $Compiler */ /** @var CompilerInterface $Compiler */
$Compiler = new PhpCompiler($configuration, $manager->getProjectPath()); $Compiler = new PhpCompiler($configuration, $manager->getProjectPath());
} }
else else
{ {
throw new NotSupportedException('The compiler extension \'' . $configuration->project->compiler->getExtension() . '\' is not supported'); throw new NotSupportedException('The compiler extension \'' . $configuration->project->getCompiler()->getExtension() . '\' is not supported');
} }
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->getName(); $build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->getName();

View file

@ -112,7 +112,7 @@
$this->package->main_execution_policy = $this->project->build->getMain(); $this->package->main_execution_policy = $this->project->build->getMain();
// Add the option to create a symbolic link to the package // Add the option to create a symbolic link to the package
if(isset($this->project->project->options['create_symlink']) && $this->project->project->options['create_symlink'] === True) if(isset($this->project->project->getOptions()['create_symlink']) && $this->project->project->getOptions()['create_symlink'] === True)
{ {
$this->package->header->Options['create_symlink'] = true; $this->package->header->Options['create_symlink'] = true;
} }
@ -126,13 +126,13 @@
($this->package->header->RuntimeConstants ?? []) ($this->package->header->RuntimeConstants ?? [])
); );
$this->package->header->CompilerExtension = $this->project->project->compiler; $this->package->header->CompilerExtension = $this->project->project->getCompiler();
$this->package->header->CompilerVersion = NCC_VERSION_NUMBER; $this->package->header->CompilerVersion = NCC_VERSION_NUMBER;
$this->package->header->Options = $this->project->project->options; $this->package->header->Options = $this->project->project->getOptions();
if($this->project->project->update_source !== null) if($this->project->project->getUpdateSource() !== null)
{ {
$this->package->header->UpdateSource = $this->project->project->update_source; $this->package->header->UpdateSource = $this->project->project->getUpdateSource();
} }
Console::outDebug('scanning project files'); Console::outDebug('scanning project files');

View file

@ -415,18 +415,18 @@
Console::outDebug('no post-installation units to execute'); Console::outDebug('no post-installation units to execute');
} }
if($package->header->UpdateSource !== null && $package->header->UpdateSource->repository !== null) if($package->header->UpdateSource !== null && $package->header->UpdateSource->getRepository() !== null)
{ {
$sources_manager = new RemoteSourcesManager(); $sources_manager = new RemoteSourcesManager();
if($sources_manager->getRemoteSource($package->header->UpdateSource->repository->getName()) === null) if($sources_manager->getRemoteSource($package->header->UpdateSource->getRepository()->getName()) === null)
{ {
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->repository->getName()); Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->getRepository()->getName());
$defined_remote_source = new DefinedRemoteSource(); $defined_remote_source = new DefinedRemoteSource();
$defined_remote_source->name = $package->header->UpdateSource->repository->getName(); $defined_remote_source->name = $package->header->UpdateSource->getRepository()->getName();
$defined_remote_source->host = $package->header->UpdateSource->repository->getHost(); $defined_remote_source->host = $package->header->UpdateSource->getRepository()->getHost();
$defined_remote_source->type = $package->header->UpdateSource->repository->getType(); $defined_remote_source->type = $package->header->UpdateSource->getRepository()->getType();
$defined_remote_source->ssl = $package->header->UpdateSource->repository->isSsl(); $defined_remote_source->ssl = $package->header->UpdateSource->getRepository()->isSsl();
$sources_manager->addRemoteSource($defined_remote_source); $sources_manager->addRemoteSource($defined_remote_source);
} }

View file

@ -125,7 +125,7 @@
$this->project_configuration = new ProjectConfiguration(); $this->project_configuration = new ProjectConfiguration();
// Set the compiler information // Set the compiler information
$this->project_configuration->project->compiler = $compiler; $this->project_configuration->project->setCompiler($compiler);
// Set the assembly information // Set the assembly information
$this->project_configuration->assembly->setName($name); $this->project_configuration->assembly->setName($name);

View file

@ -38,17 +38,17 @@
/** /**
* @var Compiler * @var Compiler
*/ */
public $compiler; private $compiler;
/** /**
* @var array * @var array
*/ */
public $options; private $options;
/** /**
* @var UpdateSource|null * @var UpdateSource|null
*/ */
public $update_source; private $update_source;
/** /**
* Public Constructor * Public Constructor
@ -59,6 +59,73 @@
$this->options = []; $this->options = [];
} }
/**
* @return Compiler
*/
public function getCompiler(): Compiler
{
return $this->compiler;
}
/**
* @param Compiler $compiler
*/
public function setCompiler(Compiler $compiler): void
{
$this->compiler = $compiler;
}
/**
* @return array
*/
public function getOptions(): array
{
return $this->options;
}
/**
* @param array $options
*/
public function setOptions(array $options): void
{
$this->options = $options;
}
/**
* @param string $key
* @param mixed $value
* @return void
*/
public function addOption(string $key, mixed $value): void
{
$this->options[$key] = $value;
}
/**
* @param string $key
* @return void
*/
public function removeOption(string $key): void
{
unset($this->options[$key]);
}
/**
* @return UpdateSource|null
*/
public function getUpdateSource(): ?UpdateSource
{
return $this->update_source;
}
/**
* @param UpdateSource|null $update_source
*/
public function setUpdateSource(?UpdateSource $update_source): void
{
$this->update_source = $update_source;
}
/** /**
* Validates the Project object * Validates the Project object
* *

View file

@ -35,14 +35,46 @@
* *
* @var string * @var string
*/ */
public $source; private $source;
/** /**
* The repository to use for the source * The repository to use for the source
* *
* @var Repository|null * @var Repository|null
*/ */
public $repository; private $repository;
/**
* @return string
*/
public function getSource(): string
{
return $this->source;
}
/**
* @param string $source
*/
public function setSource(string $source): void
{
$this->source = $source;
}
/**
* @return Repository|null
*/
public function getRepository(): ?Repository
{
return $this->repository;
}
/**
* @param Repository|null $repository
*/
public function setRepository(?Repository $repository): void
{
$this->repository = $repository;
}
/** /**
* Returns an array representation of the object * Returns an array representation of the object