1.0.0 Alpha Release #59

Merged
netkas merged 213 commits from v1.0.0_alpha into master 2023-01-29 23:27:58 +00:00
Showing only changes of commit 405f53673a - Show all commits

View file

@ -5,7 +5,9 @@
namespace ncc\Objects\ProjectConfiguration;
use ncc\Abstracts\DependencySourceType;
use ncc\Exceptions\InvalidDependencyConfiguration;
use ncc\Utilities\Functions;
use ncc\Utilities\Validate;
/**
* @author Zi Xing Narrakas
@ -84,4 +86,32 @@
return $DependencyObject;
}
/**
* Validates the dependency configuration
*
* @param bool $throw_exception
* @return bool
* @throws InvalidDependencyConfiguration
*/
public function validate(bool $throw_exception): bool
{
if(!Validate::packageName($this->Name))
{
if($throw_exception)
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency name "%s"', $this->Name));
return false;
}
if($this->Version !== null && !Validate::version($this->Version))
{
if($throw_exception)
throw new InvalidDependencyConfiguration(sprintf('Invalid dependency version "%s"', $this->Version));
return false;
}
return true;
}
}