- Updated class \ncc\Objects\ProjectConfiguration > Dependency
to use method calls rather than direct property access
This commit is contained in:
parent
628d126baf
commit
9c76d31de9
13 changed files with 217 additions and 88 deletions
|
@ -115,6 +115,7 @@ features and reduced the number of exceptions down to 15 exceptions.
|
|||
- Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException`
|
||||
- Corrected code-smell and code style issues in `\ncc\Objects > PackageLock`
|
||||
- Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpRuntime`
|
||||
- Updated class `\ncc\Objects\ProjectConfiguration > Dependency` to use method calls rather than direct property access
|
||||
|
||||
### Removed
|
||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
use ncc\Utilities\Console;
|
||||
use ncc\Utilities\Functions;
|
||||
use ncc\Utilities\Resolver;
|
||||
use ncc\Utilities\Validate;
|
||||
|
||||
class PackageManagerMenu
|
||||
{
|
||||
|
@ -395,14 +396,21 @@
|
|||
}
|
||||
}
|
||||
|
||||
$path = $package;
|
||||
$parsed_source = new RemotePackageInput($path);
|
||||
|
||||
if($parsed_source->vendor !== null && $parsed_source->package !== null && $parsed_source->source !== null)
|
||||
if(Validate::remotePackageInput($package))
|
||||
{
|
||||
try
|
||||
{
|
||||
$path = $package_manager->fetchFromSource($parsed_source->toString(), $credential);
|
||||
$parsed_source = new RemotePackageInput($package);
|
||||
if($parsed_source->vendor !== null && $parsed_source->package !== null && $parsed_source->source !== null)
|
||||
{
|
||||
$package_path = realpath($package_manager->fetchFromSource($parsed_source->toString(), $credential));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console::outError(sprintf('Invalid remote package input: %s', $package), true, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
@ -410,10 +418,14 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!file_exists($path) || !is_file($path) || !is_readable($path))
|
||||
else
|
||||
{
|
||||
Console::outError('The specified file does not exist or is not readable', true, 1);
|
||||
$package_path = realpath($package);
|
||||
}
|
||||
|
||||
if($package_path === false)
|
||||
{
|
||||
Console::outError(sprintf('The specified file \'%s\' does not exist or is not readable', $package), true, 1);
|
||||
}
|
||||
|
||||
$user_confirmation = false;
|
||||
|
@ -436,7 +448,7 @@
|
|||
|
||||
try
|
||||
{
|
||||
$package = Package::load($path);
|
||||
$package = Package::load($package_path);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
@ -503,7 +515,7 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
$dependency_package = $package_manager->getPackage($dependency->name);
|
||||
$dependency_package = $package_manager->getPackage($dependency->getName());
|
||||
}
|
||||
catch (IOException $e)
|
||||
{
|
||||
|
@ -515,7 +527,7 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
$dependency_version = $dependency_package->getVersion($dependency->version);
|
||||
$dependency_version = $dependency_package->getVersion($dependency->getVersion());
|
||||
}
|
||||
catch (IOException $e)
|
||||
{
|
||||
|
@ -533,8 +545,8 @@
|
|||
if($require_dependency)
|
||||
{
|
||||
$dependencies[] = sprintf(' %s %s',
|
||||
Console::formatColor($dependency->name, ConsoleColors::GREEN),
|
||||
Console::formatColor($dependency->version, ConsoleColors::LIGHT_MAGENTA)
|
||||
Console::formatColor($dependency->getName(), ConsoleColors::GREEN),
|
||||
Console::formatColor($dependency->getVersion(), ConsoleColors::LIGHT_MAGENTA)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -575,7 +587,7 @@
|
|||
{
|
||||
try
|
||||
{
|
||||
$package_manager->install($path, $credential, $installer_options);
|
||||
$package_manager->install($package_path, $credential, $installer_options);
|
||||
Console::out(sprintf('Package %s installed successfully', $package->assembly->package));
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
|
|
@ -354,10 +354,10 @@
|
|||
}
|
||||
|
||||
$dependency = new ProjectConfiguration\Dependency();
|
||||
$dependency->name = $package_name;
|
||||
$dependency->source_type = DependencySourceType::LOCAL;
|
||||
$dependency->version = self::versionMap($item->PackageName, $version_map);
|
||||
$dependency->source = $package_name . '.ncc';
|
||||
$dependency->setName($package_name);
|
||||
$dependency->setSourceType(DependencySourceType::LOCAL);
|
||||
$dependency->setVersion(self::versionMap($item->PackageName, $version_map));
|
||||
$dependency->setSource($package_name . '.ncc');
|
||||
$project_configuration->build->addDependency($dependency);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,30 +259,31 @@
|
|||
}
|
||||
|
||||
Console::outVerbose('Scanning for dependencies... ');
|
||||
/** @var \ncc\Objects\ProjectConfiguration\Dependency $dependency */
|
||||
foreach($selected_dependencies as $dependency)
|
||||
{
|
||||
Console::outVerbose(sprintf('processing dependency %s', $dependency->Name));
|
||||
switch($dependency->SourceType)
|
||||
Console::outVerbose(sprintf('processing dependency %s', $dependency->getName()));
|
||||
switch($dependency->getSourceType())
|
||||
{
|
||||
case DependencySourceType::STATIC:
|
||||
|
||||
try
|
||||
{
|
||||
$out_path = $lib_path . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->Name, $dependency->Version);
|
||||
$out_path = $lib_path . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->getName(), $dependency->getVersion());
|
||||
|
||||
$package = $package_lock_manager->getPackageLock()?->getPackage($dependency->Name);
|
||||
$package = $package_lock_manager->getPackageLock()?->getPackage($dependency->getName());
|
||||
if($package === null)
|
||||
{
|
||||
throw new IOException('Cannot find package lock for dependency ' . $dependency->Name);
|
||||
throw new IOException('Cannot find package lock for dependency ' . $dependency->getName());
|
||||
}
|
||||
|
||||
$version = $package->getVersion($dependency->Version);
|
||||
$version = $package->getVersion($dependency->getVersion());
|
||||
if($version === null)
|
||||
{
|
||||
throw new OperationException('Cannot find version ' . $dependency->Version . ' for dependency ' . $dependency->Name);
|
||||
throw new OperationException('Cannot find version ' . $dependency->getVersion() . ' for dependency ' . $dependency->getName());
|
||||
}
|
||||
|
||||
Console::outDebug(sprintf('copying shadow package %s=%s to %s', $dependency->Name, $dependency->Version, $out_path));
|
||||
Console::outDebug(sprintf('copying shadow package %s=%s to %s', $dependency->getName(), $dependency->getVersion(), $out_path));
|
||||
|
||||
if(!$filesystem->exists($lib_path))
|
||||
{
|
||||
|
@ -290,12 +291,12 @@
|
|||
}
|
||||
|
||||
$filesystem->copy($version->Location, $out_path);
|
||||
$dependency->Source = 'libs' . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->Name, $dependency->Version);
|
||||
$dependency->Source = 'libs' . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->getName(), $dependency->getVersion());
|
||||
|
||||
}
|
||||
catch (IOException $e)
|
||||
{
|
||||
throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e);
|
||||
throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->getName(), $e);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -324,9 +325,10 @@
|
|||
* Executes the compile process in the correct order and returns the finalized Package object
|
||||
*
|
||||
* @return Package|null
|
||||
* @throws BuildException
|
||||
* @throws IOException
|
||||
* @throws PathNotFoundException
|
||||
* @throws \ncc\Exceptions\BuildException
|
||||
* @throws \ncc\Exceptions\IOException
|
||||
* @throws \ncc\Exceptions\NotSupportedException
|
||||
* @throws \ncc\Exceptions\PathNotFoundException
|
||||
*/
|
||||
public function build(): ?Package
|
||||
{
|
||||
|
@ -466,8 +468,9 @@
|
|||
|
||||
/**
|
||||
* @return void
|
||||
* @throws IOException
|
||||
* @throws PathNotFoundException
|
||||
* @throws \ncc\Exceptions\IOException
|
||||
* @throws \ncc\Exceptions\NotSupportedException
|
||||
* @throws \ncc\Exceptions\PathNotFoundException
|
||||
*/
|
||||
public function compileExecutionPolicies(): void
|
||||
{
|
||||
|
|
|
@ -159,15 +159,15 @@
|
|||
foreach($package->dependencies as $dependency)
|
||||
{
|
||||
// Uninstall the dependency if the option Reinstall is passed on
|
||||
if(in_array(InstallPackageOptions::REINSTALL, $options, true) && $this->getPackageLockManager()?->getPackageLock()?->packageExists($dependency->name, $dependency->version))
|
||||
if(in_array(InstallPackageOptions::REINSTALL, $options, true) && $this->getPackageLockManager()?->getPackageLock()?->packageExists($dependency->getName(), $dependency->getVersion()))
|
||||
{
|
||||
if($dependency->version === null)
|
||||
if($dependency->getVersion() === 'latest')
|
||||
{
|
||||
$this->uninstallPackage($dependency->name);
|
||||
$this->uninstallPackage($dependency->getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->uninstallPackageVersion($dependency->name, $dependency->version);
|
||||
$this->uninstallPackageVersion($dependency->getName(), $dependency->getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,67 +642,67 @@
|
|||
*/
|
||||
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
|
||||
{
|
||||
if(RuntimeCache::get(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version ?? 'null')))
|
||||
if(RuntimeCache::get(sprintf('dependency_installed.%s=%s', $dependency->getName(), $dependency->getVersion())))
|
||||
{
|
||||
Console::outDebug(sprintf('dependency %s=%s already processed, skipping', $dependency->name, $dependency->version ?? 'null'));
|
||||
Console::outDebug(sprintf('dependency %s=%s already processed, skipping', $dependency->getName(), $dependency->getVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
Console::outVerbose('processing dependency ' . $dependency->name . ' (' . $dependency->version . ')');
|
||||
$dependent_package = $this->getPackage($dependency->name);
|
||||
Console::outVerbose('processing dependency ' . $dependency->getVersion() . ' (' . $dependency->getVersion() . ')');
|
||||
$dependent_package = $this->getPackage($dependency->getName());
|
||||
$dependency_met = false;
|
||||
|
||||
if ($dependent_package !== null && $dependency->version !== null && Validate::version($dependency->version))
|
||||
if ($dependent_package !== null && $dependency->getVersion() !== null && Validate::version($dependency->getVersion()))
|
||||
{
|
||||
Console::outDebug('dependency has version constraint, checking if package is installed');
|
||||
$dependent_version = $this->getPackageVersion($dependency->name, $dependency->version);
|
||||
$dependent_version = $this->getPackageVersion($dependency->getName(), $dependency->getVersion());
|
||||
if ($dependent_version !== null)
|
||||
{
|
||||
$dependency_met = true;
|
||||
}
|
||||
}
|
||||
elseif ($dependent_package !== null && $dependency->version === null)
|
||||
elseif ($dependent_package !== null && $dependency->getVersion() === null)
|
||||
{
|
||||
Console::outDebug(sprintf('dependency %s has no version specified, assuming dependency is met', $dependency->name));
|
||||
Console::outDebug(sprintf('dependency %s has no version specified, assuming dependency is met', $dependency->getName()));
|
||||
$dependency_met = true;
|
||||
}
|
||||
|
||||
Console::outDebug('dependency met: ' . ($dependency_met ? 'true' : 'false'));
|
||||
|
||||
if ($dependency->source_type !== null && !$dependency_met)
|
||||
if ($dependency->getSourceType() !== null && !$dependency_met)
|
||||
{
|
||||
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->name, $dependency->version, $package->assembly->package, $package->assembly->version));
|
||||
switch ($dependency->source_type)
|
||||
Console::outVerbose(sprintf('Installing dependency %s=%s for %s=%s', $dependency->getName(), $dependency->getVersion(), $package->assembly->package, $package->assembly->version));
|
||||
switch ($dependency->getSourceType())
|
||||
{
|
||||
case DependencySourceType::LOCAL:
|
||||
Console::outDebug('installing from local source ' . $dependency->source);
|
||||
Console::outDebug('installing from local source ' . $dependency->getSource());
|
||||
$basedir = dirname($package_path);
|
||||
|
||||
if (!file_exists($basedir . DIRECTORY_SEPARATOR . $dependency->source))
|
||||
if (!file_exists($basedir . DIRECTORY_SEPARATOR . $dependency->getSourceType()))
|
||||
{
|
||||
throw new PathNotFoundException($basedir . DIRECTORY_SEPARATOR . $dependency->source);
|
||||
throw new PathNotFoundException($basedir . DIRECTORY_SEPARATOR . $dependency->getSource());
|
||||
}
|
||||
|
||||
$this->install($basedir . DIRECTORY_SEPARATOR . $dependency->source, null, $options);
|
||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version), true);
|
||||
$this->install($basedir . DIRECTORY_SEPARATOR . $dependency->getSource(), null, $options);
|
||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->getName(), $dependency->getVersion()), true);
|
||||
break;
|
||||
|
||||
case DependencySourceType::STATIC:
|
||||
throw new PackageException('Static linking not possible, package ' . $dependency->name . ' is not installed');
|
||||
throw new PackageException('Static linking not possible, package ' . $dependency->getName() . ' is not installed');
|
||||
|
||||
case DependencySourceType::REMOTE:
|
||||
Console::outDebug('installing from remote source ' . $dependency->source);
|
||||
$this->installFromSource($dependency->source, $entry, $options);
|
||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->name, $dependency->version), true);
|
||||
Console::outDebug('installing from remote source ' . $dependency->getSource());
|
||||
$this->installFromSource($dependency->getSource(), $entry, $options);
|
||||
RuntimeCache::set(sprintf('dependency_installed.%s=%s', $dependency->getName(), $dependency->getVersion()), true);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(sprintf('Dependency source type %s is not supported', $dependency->source_type));
|
||||
throw new NotSupportedException(sprintf('Dependency source type %s is not supported', $dependency->getSourceType()));
|
||||
}
|
||||
}
|
||||
elseif(!$dependency_met)
|
||||
{
|
||||
throw new PackageException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
|
||||
throw new PackageException(sprintf('Required dependency %s=%s is not installed', $dependency->getName(), $dependency->getVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,9 +133,9 @@
|
|||
{
|
||||
foreach($this->dependencies as $dep)
|
||||
{
|
||||
if($dep->name === $dependency->name)
|
||||
if($dep->getName() === $dependency->getName())
|
||||
{
|
||||
$this->removeDependency($dep->name);
|
||||
$this->removeDependency($dep->getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@
|
|||
{
|
||||
foreach($this->dependencies as $key => $dep)
|
||||
{
|
||||
if($dep->name === $name)
|
||||
if($dep->getName() === $name)
|
||||
{
|
||||
unset($this->dependencies[$key]);
|
||||
return;
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
{
|
||||
if($dependency !== null)
|
||||
{
|
||||
$this->PackageName = $dependency->name;
|
||||
$this->Version = $dependency->version;
|
||||
$this->PackageName = $dependency->getName();
|
||||
$this->Version = $dependency->getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@
|
|||
* @param string $path
|
||||
* @param bool $bytecode
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
* @throws IOException
|
||||
*/
|
||||
public function toFile(string $path, bool $bytecode=false): void
|
||||
{
|
||||
|
@ -481,10 +481,30 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->project = Project::fromArray(Functions::array_bc($data, 'project'));
|
||||
$object->assembly = Assembly::fromArray(Functions::array_bc($data, 'assembly'));
|
||||
$object->build = Build::fromArray(Functions::array_bc($data, 'build'));
|
||||
$object->installer = Installer::fromArray(Functions::array_bc($data, 'installer'));
|
||||
$object->project = Functions::array_bc($data, 'project');
|
||||
if($object->project !== null)
|
||||
{
|
||||
$object->project = Project::fromArray($object->project);
|
||||
}
|
||||
|
||||
$object->assembly = Functions::array_bc($data, 'assembly');
|
||||
if($object->assembly !== null)
|
||||
{
|
||||
$object->assembly = Assembly::fromArray($object->assembly);
|
||||
}
|
||||
|
||||
|
||||
$object->build = Functions::array_bc($data, 'build');
|
||||
if($object->build !== null)
|
||||
{
|
||||
$object->build = Build::fromArray($object->build);
|
||||
}
|
||||
|
||||
$object->installer = Functions::array_bc($data, 'installer');
|
||||
if($object->installer !== null)
|
||||
{
|
||||
$object->installer = Installer::fromArray($object->installer);
|
||||
}
|
||||
|
||||
$execution_policies = Functions::array_bc($data, 'execution_policies');
|
||||
if(!is_null($execution_policies))
|
||||
|
|
|
@ -136,9 +136,9 @@
|
|||
{
|
||||
foreach($this->dependencies as $dep)
|
||||
{
|
||||
if($dep->name === $dependency->name)
|
||||
if($dep->getName() === $dependency->getName())
|
||||
{
|
||||
$this->removeDependency($dep->name);
|
||||
$this->removeDependency($dep->getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@
|
|||
{
|
||||
foreach($this->dependencies as $key => $dep)
|
||||
{
|
||||
if($dep->name === $name)
|
||||
if($dep->getName() === $name)
|
||||
{
|
||||
unset($this->dependencies[$key]);
|
||||
return;
|
||||
|
|
|
@ -36,32 +36,108 @@
|
|||
class Dependency implements BytecodeObjectInterface
|
||||
{
|
||||
/**
|
||||
* The name of the dependency
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* Optional. The type of source from where ncc can fetch the dependency from
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $source_type;
|
||||
private $source_type;
|
||||
|
||||
/**
|
||||
* Optional. The actual source where NCC can fetch the dependency from
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $source;
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Returns the name of the dependency
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the dependency
|
||||
*
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Returns the type of source from where ncc can fetch the dependency from
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSourceType(): ?string
|
||||
{
|
||||
return $this->source_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of source from where ncc can fetch the dependency from
|
||||
*
|
||||
* @param string|null $source_type
|
||||
* @return void
|
||||
*/
|
||||
public function setSourceType(?string $source_type): void
|
||||
{
|
||||
$this->source_type = $source_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Returns The actual source where NCC can fetch the dependency from
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSource(): ?string
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the actual source where NCC can fetch the dependency from
|
||||
*
|
||||
* @param string|null $source
|
||||
* @return void
|
||||
*/
|
||||
public function setSource(?string $source): void
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. The required version of the dependency or "latest"
|
||||
*
|
||||
* @var string|null
|
||||
* @return string
|
||||
*/
|
||||
public $version;
|
||||
public function getVersion(): string
|
||||
{
|
||||
return $this->version ?? 'latest';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the required version of the dependency or null if no version is required
|
||||
*
|
||||
* @param string|null $version
|
||||
* @return void
|
||||
*/
|
||||
public function setVersion(?string $version): void
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the dependency configuration
|
||||
|
|
|
@ -146,7 +146,7 @@
|
|||
/** @var Dependency $dependency */
|
||||
foreach($version_entry->Dependencies as $dependency)
|
||||
{
|
||||
self::import($dependency->PackageName, $dependency->version, $options);
|
||||
self::import($dependency->PackageName, $dependency->getVersion(), $options);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,11 +118,11 @@
|
|||
*
|
||||
* @param string $path
|
||||
* @param int $flags
|
||||
* @return mixed
|
||||
* @return array
|
||||
* @throws IOException
|
||||
* @throws PathNotFoundException
|
||||
*/
|
||||
public static function loadJsonFile(string $path, int $flags=0): mixed
|
||||
public static function loadJsonFile(string $path, int $flags=0): array
|
||||
{
|
||||
if(!file_exists($path))
|
||||
{
|
||||
|
@ -137,10 +137,10 @@
|
|||
*
|
||||
* @param string $json
|
||||
* @param int $flags
|
||||
* @return mixed
|
||||
* @return array
|
||||
* @throws IOException
|
||||
*/
|
||||
public static function loadJson(string $json, int $flags=0): mixed
|
||||
public static function loadJson(string $json, int $flags=0): array
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -184,6 +184,7 @@
|
|||
* @param string $path
|
||||
* @param int $flags
|
||||
* @return void
|
||||
* @throws IOException
|
||||
*/
|
||||
public static function encodeJsonFile(mixed $value, string $path, int $flags=0): void
|
||||
{
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace ncc\Utilities;
|
|||
*/
|
||||
public static function pathName(string $input): bool
|
||||
{
|
||||
if(strlen($input) === 0)
|
||||
if($input === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -299,4 +299,20 @@ namespace ncc\Utilities;
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/***
|
||||
* Returns True if the given remote package input is valid
|
||||
*
|
||||
* @param string $input
|
||||
* @return bool
|
||||
*/
|
||||
public static function remotePackageInput(string $input): bool
|
||||
{
|
||||
if(preg_match(RegexPatterns::REMOTE_PACKAGE, $input))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue