1.0.0 Alpha Release #59
1 changed files with 30 additions and 0 deletions
|
@ -5,7 +5,9 @@
|
||||||
namespace ncc\Objects\ProjectConfiguration;
|
namespace ncc\Objects\ProjectConfiguration;
|
||||||
|
|
||||||
use ncc\Abstracts\DependencySourceType;
|
use ncc\Abstracts\DependencySourceType;
|
||||||
|
use ncc\Exceptions\InvalidDependencyConfiguration;
|
||||||
use ncc\Utilities\Functions;
|
use ncc\Utilities\Functions;
|
||||||
|
use ncc\Utilities\Validate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zi Xing Narrakas
|
* @author Zi Xing Narrakas
|
||||||
|
@ -84,4 +86,32 @@
|
||||||
|
|
||||||
return $DependencyObject;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue