- Updated class \ncc\Objects > CliHelpSection
to use method calls rather than direct property access
- Updated class `\ncc\Objects > ComposerJson` to use method calls rather than direct property access - Updated class `\ncc\Objects > ComposerLock` to use method calls rather than direct property access - Updated class `\ncc\Objects > DefinedRemoteSource` to use method calls rather than direct property access - Updated class `\ncc\Objects > HttpRequest` to use method calls rather than direct property access and implemented `SerializableObjectInterface` - Updated class `\ncc\Objects > HttpResponse` to use method calls rather than direct property access and implemented `SerializableObjectInterface` - Fixed hash comparisons to use `hash_equals` implementations to combat against Timing Attacks
This commit is contained in:
parent
eeffb15eb7
commit
42c26c92a0
16 changed files with 1338 additions and 363 deletions
|
@ -25,6 +25,7 @@ features and reduced the number of exceptions down to 15 exceptions.
|
|||
### Fixed
|
||||
- Fixed MITM attack vector in `\ncc\Classes > HttpClient > prepareCurl()`
|
||||
- Fixed all @throw tags in the project to use the correct exception class
|
||||
- Fixed hash comparisons to use `hash_equals` implementations to combat against Timing Attacks
|
||||
|
||||
### Changed
|
||||
- Corrected code-smell and code style issues in `\ncc\Classes > HttpClient`
|
||||
|
@ -177,6 +178,14 @@ features and reduced the number of exceptions down to 15 exceptions.
|
|||
and implemented `BytecodeObjectInterface`
|
||||
- Updated class `\ncc\Objects\SymlinkDictionary > SymlinkEntry` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects\Vault\Password > AccessToken` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects > CliHelpSection` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects > ComposerJson` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects > ComposerLock` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects > DefinedRemoteSource` to use method calls rather than direct property access
|
||||
- Updated class `\ncc\Objects > HttpRequest` to use method calls rather than direct property access and implemented
|
||||
`SerializableObjectInterface`
|
||||
- Updated class `\ncc\Objects > HttpResponse` to use method calls rather than direct property access and implemented
|
||||
`SerializableObjectInterface`
|
||||
|
||||
### Removed
|
||||
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
|
||||
|
|
|
@ -866,7 +866,7 @@
|
|||
try
|
||||
{
|
||||
$definedEntry = DefinedRemoteSource::fromArray(Functions::loadJsonFile($repo_path, Functions::FORCE_ARRAY));
|
||||
if(!$source_manager->getRemoteSource($definedEntry->name))
|
||||
if(!$source_manager->getRemoteSource($definedEntry->getName()))
|
||||
$source_manager->addRemoteSource($definedEntry);
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
|
|
@ -105,7 +105,7 @@ namespace ncc\CLI\Management;
|
|||
Console::out('Remote sources:', 1);
|
||||
foreach($sources as $source)
|
||||
{
|
||||
Console::out(' - ' . $source->name . ' (' . $source->host . ')', 1);
|
||||
Console::out(' - ' . $source->getName() . ' (' . $source->getHost() . ')', 1);
|
||||
}
|
||||
|
||||
Console::out('Total: ' . count($sources), 1);
|
||||
|
@ -153,10 +153,10 @@ namespace ncc\CLI\Management;
|
|||
|
||||
$source_manager = new RemoteSourcesManager();
|
||||
$source = new DefinedRemoteSource();
|
||||
$source->name = $name;
|
||||
$source->type = $type;
|
||||
$source->host = $host;
|
||||
$source->ssl = $ssl;
|
||||
$source->setName($name);
|
||||
$source->setType($type);
|
||||
$source->setHost($host);
|
||||
$source->setSsl($ssl);
|
||||
|
||||
if(!$source_manager->addRemoteSource($source))
|
||||
{
|
||||
|
|
|
@ -212,15 +212,15 @@
|
|||
$filesystem->mkdir($base_dir . DIRECTORY_SEPARATOR . 'build');
|
||||
$version_map = self::getVersionMap($composer_lock);
|
||||
|
||||
foreach ($composer_lock->Packages as $package)
|
||||
foreach ($composer_lock->getPackages() as $package)
|
||||
{
|
||||
$package_path = $base_dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package->name;
|
||||
$package_path = $base_dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package->getName();
|
||||
|
||||
// Load the composer lock file
|
||||
$composer_package = $composer_lock->getPackage($package->name);
|
||||
$composer_package = $composer_lock->getPackage($package->getName());
|
||||
if ($composer_package === null)
|
||||
{
|
||||
throw new PackageException(sprintf('Package "%s" not found in composer lock file', $package->name));
|
||||
throw new PackageException(sprintf('Package "%s" not found in composer lock file', $package->getName()));
|
||||
}
|
||||
|
||||
// Convert it to an NCC project configuration
|
||||
|
@ -250,9 +250,9 @@
|
|||
private static function getVersionMap(ComposerLock $composerLock): array
|
||||
{
|
||||
$version_map = [];
|
||||
foreach($composerLock->Packages as $package)
|
||||
foreach($composerLock->getPackges() as $package)
|
||||
{
|
||||
$version_map[$package->name] = $package->version;
|
||||
$version_map[$package->getName()] = $package->getVersion();
|
||||
}
|
||||
return $version_map;
|
||||
}
|
||||
|
@ -310,20 +310,12 @@
|
|||
{
|
||||
// Generate a new project configuration object
|
||||
$project_configuration = new ProjectConfiguration();
|
||||
$project_configuration->assembly->setName($composer_package->getName());
|
||||
$project_configuration->assembly->setDescription($composer_package->getDescription());
|
||||
|
||||
if (isset($composer_package->name))
|
||||
if(isset($version_map[$composer_package->getName()]))
|
||||
{
|
||||
$project_configuration->assembly->setName($composer_package->name);
|
||||
}
|
||||
|
||||
if (isset($composer_package->description))
|
||||
{
|
||||
$project_configuration->assembly->setDescription($composer_package->description);
|
||||
}
|
||||
|
||||
if(isset($version_map[$composer_package->name]))
|
||||
{
|
||||
$project_configuration->assembly->setVersion(self::versionMap($composer_package->name, $version_map));
|
||||
$project_configuration->assembly->setVersion(self::versionMap($composer_package->getName(), $version_map));
|
||||
}
|
||||
|
||||
if($project_configuration->assembly->getVersion() === null || $project_configuration->assembly->getVersion() === '')
|
||||
|
@ -333,17 +325,17 @@
|
|||
|
||||
|
||||
$project_configuration->assembly->setUuid(Uuid::v1()->toRfc4122());
|
||||
$project_configuration->assembly->setPackage(self::toPackageName($composer_package->name));
|
||||
$project_configuration->assembly->setPackage(self::toPackageName($composer_package->getName()));
|
||||
|
||||
// Add the update source
|
||||
$project_configuration->project->setUpdateSource(new ProjectConfiguration\UpdateSource());
|
||||
$project_configuration->project->getUpdateSource()?->setSource(sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->name)));
|
||||
$project_configuration->project->getUpdateSource()?->setSource(sprintf('%s@composer', str_ireplace('\\', '/', $composer_package->getName())));
|
||||
$project_configuration->project->getUpdateSource()?->setRepository(null);
|
||||
|
||||
// Process the dependencies
|
||||
if($composer_package->require !== null && count($composer_package->require) > 0)
|
||||
if($composer_package->getRequire() !== null && count($composer_package->getRequire()) > 0)
|
||||
{
|
||||
foreach ($composer_package->require as $item)
|
||||
foreach ($composer_package->getRequire() as $item)
|
||||
{
|
||||
// Check if the dependency is already in the project configuration
|
||||
$package_name = self::toPackageName($item->getPackageName());
|
||||
|
@ -674,7 +666,7 @@
|
|||
$filesystem = new Filesystem();
|
||||
|
||||
// Process the source files
|
||||
if ($composer_package->autoload !== null)
|
||||
if ($composer_package->getAutoload() !== null)
|
||||
{
|
||||
$source_directory = $package_path . DIRECTORY_SEPARATOR . '.src';
|
||||
|
||||
|
@ -688,10 +680,10 @@
|
|||
$static_files = [];
|
||||
|
||||
// Extract all the source directories
|
||||
if ($composer_package->autoload->getPsr4() !== null && count($composer_package->autoload->getPsr4()) > 0)
|
||||
if ($composer_package->getAutoloadDev()->getPsr4() !== null && count($composer_package->getAutoload()->getPsr4()) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-4 source directories');
|
||||
foreach ($composer_package->autoload->getPsr4() as $namespace_pointer)
|
||||
foreach ($composer_package->getAutoload()->getPsr4() as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->getPath() !== null && !in_array($namespace_pointer->getPath(), $source_directories, true))
|
||||
{
|
||||
|
@ -700,10 +692,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ($composer_package->autoload->getPsr0() !== null && count($composer_package->autoload->getPsr0()) > 0)
|
||||
if ($composer_package->getAutoload()->getPsr0() !== null && count($composer_package->getAutoload()->getPsr0()) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting PSR-0 source directories');
|
||||
foreach ($composer_package->autoload->getPsr0() as $namespace_pointer)
|
||||
foreach ($composer_package->getAutoload()->getPsr0() as $namespace_pointer)
|
||||
{
|
||||
if ($namespace_pointer->getPath() !== null && !in_array($namespace_pointer->getPath(), $source_directories, true))
|
||||
{
|
||||
|
@ -712,10 +704,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
if ($composer_package->autoload->getFiles() !== null && count($composer_package->autoload->getFiles()) > 0)
|
||||
if ($composer_package->getAutoload()->getFiles() !== null && count($composer_package->getAutoload()->getFiles()) > 0)
|
||||
{
|
||||
Console::outVerbose('Extracting static files');
|
||||
foreach ($composer_package->autoload->getFiles() as $file)
|
||||
foreach ($composer_package->getAutoload()->getFiles() as $file)
|
||||
{
|
||||
$static_files[] = $package_path . DIRECTORY_SEPARATOR . $file;
|
||||
}
|
||||
|
@ -751,7 +743,7 @@
|
|||
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $item->getPathName());
|
||||
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->name));
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->getName()));
|
||||
$filesystem->copy($item->getPathName(), $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
}
|
||||
}
|
||||
|
@ -763,7 +755,7 @@
|
|||
foreach ($static_files as $file)
|
||||
{
|
||||
$parsed_path = str_ireplace($package_path . DIRECTORY_SEPARATOR, '', $file);
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->name));
|
||||
Console::outDebug(sprintf('copying file %s for package %s', $parsed_path, $composer_package->getName()));
|
||||
$filesystem->copy($file, $source_directory . DIRECTORY_SEPARATOR . $parsed_path);
|
||||
unset($file);
|
||||
}
|
||||
|
@ -789,16 +781,16 @@
|
|||
// Check configuration if composer.extension.display_licenses is set
|
||||
if($filesystem->exists($package_path . DIRECTORY_SEPARATOR . $license_file) && Functions::cbool(Functions::getConfigurationProperty('composer.extension.display_licenses')))
|
||||
{
|
||||
Console::out(sprintf('License for package %s:', $composer_package->name));
|
||||
Console::out(sprintf('License for package %s:', $composer_package->getName()));
|
||||
Console::out(IO::fread($package_path . DIRECTORY_SEPARATOR . $license_file));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(Functions::cbool(!is_null($composer_package->authors) && count($composer_package->authors) > 0 && Functions::getConfigurationProperty('composer.extension.display_authors')))
|
||||
if(Functions::cbool(!is_null($composer_package->getAuthors()) && count($composer_package->getAuthors()) > 0 && Functions::getConfigurationProperty('composer.extension.display_authors')))
|
||||
{
|
||||
Console::out(sprintf('Authors for package %s:', $composer_package->name));
|
||||
foreach($composer_package->authors as $author)
|
||||
Console::out(sprintf('Authors for package %s:', $composer_package->getName()));
|
||||
foreach($composer_package->getAuthors() as $author)
|
||||
{
|
||||
Console::out(sprintf(' - %s', $author->getName()));
|
||||
|
||||
|
|
|
@ -55,11 +55,11 @@
|
|||
public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
|
||||
{
|
||||
$httpRequest = new HttpRequest();
|
||||
$protocol = ($definedRemoteSource->ssl ? "https" : "http");
|
||||
$protocol = ($definedRemoteSource->isSsl() ? "https" : "http");
|
||||
$owner_f = str_ireplace("/", "%2F", $packageInput->vendor);
|
||||
$owner_f = str_ireplace(".", "%2F", $owner_f);
|
||||
$repository = urlencode($packageInput->package);
|
||||
$httpRequest->Url = $protocol . '://' . $definedRemoteSource->host . "/repos/$owner_f/$repository";
|
||||
$httpRequest->setUrl($protocol . '://' . $definedRemoteSource->getHost() . "/repos/$owner_f/$repository");
|
||||
$response_decoded = self::getJsonResponse($httpRequest, $entry);
|
||||
|
||||
$query = new RepositoryQueryResults();
|
||||
|
@ -119,11 +119,11 @@
|
|||
private static function getReleases(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): array
|
||||
{
|
||||
$httpRequest = new HttpRequest();
|
||||
$protocol = ($definedRemoteSource->ssl ? "https" : "http");
|
||||
$protocol = ($definedRemoteSource->isSsl() ? "https" : "http");
|
||||
$owner_f = str_ireplace("/", "%2F", $packageInput->vendor);
|
||||
$owner_f = str_ireplace(".", "%2F", $owner_f);
|
||||
$repository = urlencode($packageInput->package);
|
||||
$httpRequest->Url = $protocol . '://' . $definedRemoteSource->host . "/repos/$owner_f/$repository/releases";
|
||||
$httpRequest->setUrl($protocol . '://' . $definedRemoteSource->getHost() . "/repos/$owner_f/$repository/releases");
|
||||
$response_decoded = self::getJsonResponse($httpRequest, $entry);
|
||||
|
||||
if(count($response_decoded) === 0)
|
||||
|
@ -190,19 +190,19 @@
|
|||
*/
|
||||
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
|
||||
{
|
||||
$httpRequest->Type = HttpRequestType::GET;
|
||||
$httpRequest->setType(HttpRequestType::GET);
|
||||
$httpRequest = Functions::prepareGitServiceRequest($httpRequest, $entry, false);
|
||||
$httpRequest->Headers[] = 'X-GitHub-Api-Version: 2022-11-28';
|
||||
$httpRequest->Headers[] = 'Accept: application/vnd.github+json';
|
||||
$httpRequest->addHeader('X-GitHub-Api-Version: 2022-11-28');
|
||||
$httpRequest->addHeader('Accept: application/vnd.github+json');
|
||||
|
||||
$response = HttpClient::request($httpRequest, true);
|
||||
|
||||
if ($response->StatusCode !== 200)
|
||||
if ($response->getStatusCode() !== 200)
|
||||
{
|
||||
throw new GitException(sprintf('Github returned an error (%s): %s', $response->StatusCode, $response->Body));
|
||||
throw new GitException(sprintf('Github returned an error (%s): %s', $response->getStatusCode(), $response->getBody()));
|
||||
}
|
||||
|
||||
return Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||
return Functions::loadJson($response->getBody(), Functions::FORCE_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -221,7 +221,7 @@
|
|||
|
||||
if (count($releases) === 0)
|
||||
{
|
||||
throw new GitException(sprintf('No releases found for %s/%s on %s.', $packageInput->vendor, $packageInput->package, $definedRemoteSource->host));
|
||||
throw new GitException(sprintf('No releases found for %s/%s on %s.', $packageInput->vendor, $packageInput->package, $definedRemoteSource->getHost()));
|
||||
}
|
||||
|
||||
if ($packageInput->version === Versions::LATEST)
|
||||
|
@ -265,7 +265,7 @@
|
|||
|
||||
if ($selected_version === null)
|
||||
{
|
||||
throw new GitException(sprintf('Version %s not found for %s/%s on %s.', $packageInput->version, $packageInput->vendor, $packageInput->package, $definedRemoteSource->host));
|
||||
throw new GitException(sprintf('Version %s not found for %s/%s on %s.', $packageInput->version, $packageInput->vendor, $packageInput->package, $definedRemoteSource->getHost()));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -275,7 +275,7 @@
|
|||
|
||||
if (!isset($releases[$selected_version]))
|
||||
{
|
||||
throw new GitException(sprintf('Version %s not found for %s/%s on %s.', $packageInput->version, $packageInput->vendor, $packageInput->package, $definedRemoteSource->host));
|
||||
throw new GitException(sprintf('Version %s not found for %s/%s on %s.', $packageInput->version, $packageInput->vendor, $packageInput->package, $definedRemoteSource->getHost()));
|
||||
}
|
||||
|
||||
return $releases[$selected_version];
|
||||
|
|
|
@ -56,22 +56,22 @@
|
|||
public static function getGitRepository(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry=null): RepositoryQueryResults
|
||||
{
|
||||
$httpRequest = new HttpRequest();
|
||||
$protocol = ($definedRemoteSource->ssl ? "https" : "http");
|
||||
$protocol = ($definedRemoteSource->isSsl() ? "https" : "http");
|
||||
$owner_f = str_ireplace("/", "%2F", $packageInput->vendor);
|
||||
$owner_f = str_ireplace(".", "%2F", $owner_f);
|
||||
$project_f = str_ireplace("/", "%2F", $packageInput->package);
|
||||
$project_f = str_ireplace(".", "%2F", $project_f);
|
||||
$httpRequest->Url = $protocol . '://' . $definedRemoteSource->host . "/api/v4/projects/$owner_f%2F$project_f";
|
||||
$httpRequest->setUrl($protocol . '://' . $definedRemoteSource->getHost() . "/api/v4/projects/$owner_f%2F$project_f");
|
||||
$httpRequest = Functions::prepareGitServiceRequest($httpRequest, $entry);
|
||||
|
||||
$response = HttpClient::request($httpRequest, true);
|
||||
|
||||
if($response->StatusCode !== 200)
|
||||
if($response->getStatusCode() !== 200)
|
||||
{
|
||||
throw new GitException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
|
||||
throw new GitException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->getStatusCode()));
|
||||
}
|
||||
|
||||
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||
$response_decoded = Functions::loadJson($response->getBody(), Functions::FORCE_ARRAY);
|
||||
|
||||
$query = new RepositoryQueryResults();
|
||||
$query->Files->GitSshUrl = ($response_decoded['ssh_url_to_repo'] ?? null);
|
||||
|
@ -171,7 +171,7 @@
|
|||
*/
|
||||
public static function getNccPackage(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
|
||||
{
|
||||
throw new NotSupportedException(sprintf('The given repository source "%s" does not support ncc packages.', $definedRemoteSource->host));
|
||||
throw new NotSupportedException(sprintf('The given repository source "%s" does not support ncc packages.', $definedRemoteSource->getHost()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,23 +190,23 @@
|
|||
private static function getReleases(string $owner, string $repository, DefinedRemoteSource $definedRemoteSource, ?Entry $entry): array
|
||||
{
|
||||
$httpRequest = new HttpRequest();
|
||||
$protocol = ($definedRemoteSource->ssl ? "https" : "http");
|
||||
$protocol = ($definedRemoteSource->isSsl() ? "https" : "http");
|
||||
$owner_f = str_ireplace("/", "%2F", $owner);
|
||||
$owner_f = str_ireplace(".", "%2F", $owner_f);
|
||||
$repository_f = str_ireplace("/", "%2F", $repository);
|
||||
$repository_f = str_ireplace(".", "%2F", $repository_f);
|
||||
|
||||
$httpRequest->Url = $protocol . '://' . $definedRemoteSource->host . "/api/v4/projects/$owner_f%2F$repository_f/releases";
|
||||
$httpRequest->setUrl($protocol . '://' . $definedRemoteSource->getHost() . "/api/v4/projects/$owner_f%2F$repository_f/releases");
|
||||
$httpRequest = Functions::prepareGitServiceRequest($httpRequest, $entry);
|
||||
|
||||
$response = HttpClient::request($httpRequest, true);
|
||||
|
||||
if($response->StatusCode !== 200)
|
||||
if($response->getStatusCode() !== 200)
|
||||
{
|
||||
throw new GitException(sprintf('Failed to fetch releases for repository %s/%s. Status code: %s', $owner, $repository, $response->StatusCode));
|
||||
throw new GitException(sprintf('Failed to fetch releases for repository %s/%s. Status code: %s', $owner, $repository, $response->getStatusCode()));
|
||||
}
|
||||
|
||||
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
|
||||
$response_decoded = Functions::loadJson($response->getBody(), Functions::FORCE_ARRAY);
|
||||
|
||||
if(count($response_decoded) === 0)
|
||||
{
|
||||
|
|
|
@ -43,15 +43,15 @@ namespace ncc\Classes;
|
|||
*/
|
||||
private static function prepareCurl(HttpRequest $request): CurlHandle
|
||||
{
|
||||
$curl = curl_init($request->Url);
|
||||
$curl = curl_init($request->geturl());
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($curl, CURLOPT_MAXREDIRS, 5);
|
||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $request->Headers);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->Type);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $request->getHeaders());
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getType());
|
||||
curl_setopt($curl, CURLOPT_NOPROGRESS, false);
|
||||
|
||||
curl_setopt($curl, CURLOPT_PROGRESSFUNCTION, static function($curl, $downloadSize, $downloaded)
|
||||
|
@ -73,7 +73,7 @@ namespace ncc\Classes;
|
|||
}
|
||||
});
|
||||
|
||||
switch($request->Type)
|
||||
switch($request->getType())
|
||||
{
|
||||
case HttpRequestType::GET:
|
||||
curl_setopt($curl, CURLOPT_HTTPGET, true);
|
||||
|
@ -81,17 +81,17 @@ namespace ncc\Classes;
|
|||
|
||||
case HttpRequestType::POST:
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
if($request->Body !== null)
|
||||
if($request->getBody() !== null)
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->Body);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getBody());
|
||||
}
|
||||
break;
|
||||
|
||||
case HttpRequestType::PUT:
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
if($request->Body !== null)
|
||||
if($request->getBody() !== null)
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->Body);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getBody());
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -100,16 +100,16 @@ namespace ncc\Classes;
|
|||
break;
|
||||
}
|
||||
|
||||
if (is_array($request->Authentication))
|
||||
if (is_array($request->getAuthentication()))
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_USERPWD, $request->Authentication[0] . ':' . $request->Authentication[1]);
|
||||
curl_setopt($curl, CURLOPT_USERPWD, $request->getAuthentication()[0] . ':' . $request->getAuthentication()[1]);
|
||||
}
|
||||
else if (is_string($request->Authentication))
|
||||
else if (is_string($request->getAuthentication()))
|
||||
{
|
||||
curl_setopt($curl, CURLOPT_USERPWD, $request->Authentication);
|
||||
curl_setopt($curl, CURLOPT_USERPWD, $request->getAuthentication());
|
||||
}
|
||||
|
||||
foreach ($request->Options as $option => $value)
|
||||
foreach ($request->getOptions() as $option => $value)
|
||||
{
|
||||
curl_setopt($curl, $option, $value);
|
||||
}
|
||||
|
@ -140,16 +140,16 @@ namespace ncc\Classes;
|
|||
|
||||
$curl = self::prepareCurl($httpRequest);
|
||||
|
||||
Console::outDebug(sprintf(' => %s request %s', $httpRequest->Type, $httpRequest->Url));
|
||||
Console::outDebug(sprintf(' => %s request %s', $httpRequest->getType(), $httpRequest->getUrl()));
|
||||
|
||||
if($httpRequest->Headers !== null && count($httpRequest->Headers) > 0)
|
||||
if(count($httpRequest->getHeaders()) > 0)
|
||||
{
|
||||
Console::outDebug(sprintf(' => headers: %s', implode(', ', $httpRequest->Headers)));
|
||||
Console::outDebug(sprintf(' => headers: %s', implode(', ', $httpRequest->getHeaders())));
|
||||
}
|
||||
|
||||
if($httpRequest->Body !== null)
|
||||
if($httpRequest->getBody() !== null)
|
||||
{
|
||||
Console::outDebug(sprintf(' => body: %s', $httpRequest->Body));
|
||||
Console::outDebug(sprintf(' => body: %s', $httpRequest->getBody()));
|
||||
}
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
@ -166,13 +166,13 @@ namespace ncc\Classes;
|
|||
$body = substr($response, $headerSize);
|
||||
|
||||
$httpResponse = new HttpResponse();
|
||||
$httpResponse->StatusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
$httpResponse->Headers = self::parseHeaders($headers);
|
||||
$httpResponse->Body = $body;
|
||||
$httpResponse->setStatusCode(curl_getinfo($curl, CURLINFO_HTTP_CODE));
|
||||
$httpResponse->setHeaders(self::parseHeaders($headers));
|
||||
$httpResponse->setBody($body);
|
||||
|
||||
Console::outDebug(sprintf(' <= %s response', $httpResponse->StatusCode));
|
||||
Console::outDebug(sprintf(' <= headers: %s', (implode(', ', $httpResponse->Headers))));
|
||||
Console::outDebug(sprintf(' <= body: %s', $httpResponse->Body));
|
||||
Console::outDebug(sprintf(' <= %s response', $httpResponse->getStatusCode()));
|
||||
Console::outDebug(sprintf(' <= headers: %s', (implode(', ', $httpResponse->getHeaders()))));
|
||||
Console::outDebug(sprintf(' <= body: %s', $httpResponse->getBody()));
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
|
|
|
@ -423,10 +423,10 @@
|
|||
Console::outVerbose('Adding remote source ' . $package->header->getUpdateSource()->getRepository()->getName());
|
||||
|
||||
$defined_remote_source = new DefinedRemoteSource();
|
||||
$defined_remote_source->name = $package->header->getUpdateSource()?->getRepository()->getName();
|
||||
$defined_remote_source->host = $package->header->getUpdateSource()?->getRepository()->getHost();
|
||||
$defined_remote_source->type = $package->header->getUpdateSource()?->getRepository()->getType();
|
||||
$defined_remote_source->ssl = $package->header->getUpdateSource()?->getRepository()->isSsl();
|
||||
$defined_remote_source->setName($package->header->getUpdateSource()?->getRepository()?->getName());
|
||||
$defined_remote_source->setHost($package->header->getUpdateSource()?->getRepository()?->getHost());
|
||||
$defined_remote_source->setType($package->header->getUpdateSource()?->getRepository()?->getType());
|
||||
$defined_remote_source->setSsl($package->header->getUpdateSource()?->getRepository()?->isSsl());
|
||||
|
||||
$sources_manager->addRemoteSource($defined_remote_source);
|
||||
}
|
||||
|
|
|
@ -109,8 +109,10 @@
|
|||
{
|
||||
foreach($this->Sources as $existingSource)
|
||||
{
|
||||
if($existingSource->name === $source->name)
|
||||
if($existingSource->getName() === $source->getName())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->Sources[] = $source;
|
||||
|
@ -127,7 +129,7 @@
|
|||
{
|
||||
foreach($this->Sources as $source)
|
||||
{
|
||||
if($source->name === $name)
|
||||
if($source->getName() === $name)
|
||||
{
|
||||
return $source;
|
||||
}
|
||||
|
@ -146,7 +148,7 @@
|
|||
{
|
||||
foreach($this->Sources as $index => $source)
|
||||
{
|
||||
if($source->name === $name)
|
||||
if($source->getName() === $name)
|
||||
{
|
||||
unset($this->Sources[$index]);
|
||||
return true;
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
|
@ -34,21 +34,21 @@
|
|||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $Parameters;
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* A description of the option
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $Description;
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* The default value of the option
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $Default;
|
||||
private $default;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
|
@ -59,9 +59,57 @@
|
|||
*/
|
||||
public function __construct(?array $parameters=null, ?string $description=null, ?string $default=null)
|
||||
{
|
||||
$this->Parameters = $parameters;
|
||||
$this->Description = $description;
|
||||
$this->Default = $default;
|
||||
$this->parameters = $parameters;
|
||||
$this->description = $description;
|
||||
$this->default = $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getParameters(): ?array
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $parameters
|
||||
*/
|
||||
public function setParameters(?array $parameters): void
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription(): ?string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $description
|
||||
*/
|
||||
public function setDescription(?string $description): void
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDefault(): ?string
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $default
|
||||
*/
|
||||
public function setDefault(?string $default): void
|
||||
{
|
||||
$this->default = $default;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,9 +120,9 @@
|
|||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'parameters' => $this->Parameters,
|
||||
'description' => $this->Description,
|
||||
'default' => $this->Default
|
||||
'parameters' => $this->parameters,
|
||||
'description' => $this->description,
|
||||
'default' => $this->default
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -90,17 +138,17 @@
|
|||
|
||||
if(isset($data['parameters']))
|
||||
{
|
||||
$object->Parameters = $data['parameters'];
|
||||
$object->parameters = $data['parameters'];
|
||||
}
|
||||
|
||||
if(isset($data['description']))
|
||||
{
|
||||
$object->Description = $data['description'];
|
||||
$object->description = $data['description'];
|
||||
}
|
||||
|
||||
if(isset($data['default']))
|
||||
{
|
||||
$object->Default = $data['default'];
|
||||
$object->default = $data['default'];
|
||||
}
|
||||
|
||||
return $object;
|
||||
|
@ -117,12 +165,12 @@
|
|||
{
|
||||
$out = [];
|
||||
|
||||
if(count($this->Parameters) > 0)
|
||||
if(count($this->parameters) > 0)
|
||||
{
|
||||
if($param_padding > 0)
|
||||
{
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
$result = str_pad(implode(' ', $this->Parameters), $param_padding, ' ', STR_PAD_RIGHT);
|
||||
$result = str_pad(implode(' ', $this->parameters), $param_padding, ' ', STR_PAD_RIGHT);
|
||||
|
||||
if(!$basic)
|
||||
{
|
||||
|
@ -133,22 +181,22 @@
|
|||
}
|
||||
elseif($basic)
|
||||
{
|
||||
$out[] .= implode(' ', $this->Parameters);
|
||||
$out[] .= implode(' ', $this->parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
$out[] .= Console::formatColor(implode(' ', $this->Parameters), ConsoleColors::GREEN);
|
||||
$out[] .= Console::formatColor(implode(' ', $this->parameters), ConsoleColors::GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->Description !== null)
|
||||
if($this->description !== null)
|
||||
{
|
||||
$out[] = $this->Description;
|
||||
$out[] = $this->description;
|
||||
}
|
||||
|
||||
if($this->Default !== null)
|
||||
if($this->default !== null)
|
||||
{
|
||||
$out[] = '(Default: ' . $this->Default . ')';
|
||||
$out[] = '(Default: ' . $this->default . ')';
|
||||
}
|
||||
|
||||
return implode(' ', $out);
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
|
@ -40,7 +40,7 @@
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* A short description of the package. Usually
|
||||
|
@ -48,7 +48,7 @@
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public $description;
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* The version of the package, in most cases this is not
|
||||
|
@ -60,14 +60,14 @@
|
|||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $version;
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* The type of package, it defaults to library
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* An array of keywords that the package is related to.
|
||||
|
@ -82,21 +82,21 @@
|
|||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $keywords;
|
||||
private $keywords;
|
||||
|
||||
/**
|
||||
* A URL to the website of the project
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $homepage;
|
||||
private $homepage;
|
||||
|
||||
/**
|
||||
* A relative path to the readme document
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $readme;
|
||||
private $readme;
|
||||
|
||||
/**
|
||||
* Release date of the version
|
||||
|
@ -105,7 +105,7 @@
|
|||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $time;
|
||||
private $time;
|
||||
|
||||
/**
|
||||
* The license of the package. This can either be a string or
|
||||
|
@ -113,17 +113,17 @@
|
|||
*
|
||||
* @var string|string[]|null
|
||||
*/
|
||||
public $license;
|
||||
private $license;
|
||||
|
||||
/**
|
||||
* @var Author[]|null
|
||||
*/
|
||||
public $authors;
|
||||
private $authors;
|
||||
|
||||
/**
|
||||
* @var Support|null
|
||||
*/
|
||||
public $support;
|
||||
private $support;
|
||||
|
||||
/**
|
||||
* Map of packages required by this package. The package
|
||||
|
@ -131,7 +131,7 @@
|
|||
*
|
||||
* @var PackageLink[]|null
|
||||
*/
|
||||
public $require;
|
||||
private $require;
|
||||
|
||||
/**
|
||||
* Map of packages required for developing this package, or running tests,
|
||||
|
@ -141,7 +141,7 @@
|
|||
*
|
||||
* @var PackageLink[]|null
|
||||
*/
|
||||
public $require_dev;
|
||||
private $require_dev;
|
||||
|
||||
/**
|
||||
* Map of packages that conflict with this version of this package. They will
|
||||
|
@ -149,7 +149,7 @@
|
|||
*
|
||||
* @var PackageLink[]|null
|
||||
*/
|
||||
public $conflict;
|
||||
private $conflict;
|
||||
|
||||
/**
|
||||
* Map of packages that are replaced by this package. This allows you to fork a
|
||||
|
@ -159,7 +159,7 @@
|
|||
*
|
||||
* @var PackageLink[]|null
|
||||
*/
|
||||
public $replace;
|
||||
private $replace;
|
||||
|
||||
/**
|
||||
* Map of packages that are provided by this package. This is mostly useful for
|
||||
|
@ -169,7 +169,7 @@
|
|||
*
|
||||
* @var PackageLink[]|null
|
||||
*/
|
||||
public $provide;
|
||||
private $provide;
|
||||
|
||||
/**
|
||||
* Suggested packages that can enhance or work well with this package. These are
|
||||
|
@ -179,35 +179,35 @@
|
|||
*
|
||||
* @var Suggestion[]|null
|
||||
*/
|
||||
public $suggest;
|
||||
private $suggest;
|
||||
|
||||
/**
|
||||
* Autoload mapping for a PHP autoloader.
|
||||
*
|
||||
* @var Autoloader|null
|
||||
*/
|
||||
public $autoload;
|
||||
private $autoload;
|
||||
|
||||
/**
|
||||
* This section allows defining autoload rules for development purposes.
|
||||
*
|
||||
* @var Autoloader|null
|
||||
*/
|
||||
public $autoload_dev;
|
||||
private $autoload_dev;
|
||||
|
||||
/**
|
||||
* A list of paths which should get appended to PHP's include_path.
|
||||
*
|
||||
* @var string[]|null
|
||||
*/
|
||||
public $include_path;
|
||||
private $include_path;
|
||||
|
||||
/**
|
||||
* Defines the installation target.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $target_directory;
|
||||
private $target_directory;
|
||||
|
||||
/**
|
||||
* This defines the default behavior for filtering packages by
|
||||
|
@ -222,21 +222,21 @@
|
|||
*
|
||||
* @var ComposerPackageTypes|null
|
||||
*/
|
||||
public $minimum_stability;
|
||||
private $minimum_stability;
|
||||
|
||||
/**
|
||||
* Custom package repositories to use.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $repositories;
|
||||
private $repositories;
|
||||
|
||||
/**
|
||||
* A set of configuration options. It is only used for projects.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $configuration;
|
||||
private $configuration;
|
||||
|
||||
/**
|
||||
* Composer allows you to hook into various parts of the installation
|
||||
|
@ -244,35 +244,35 @@
|
|||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $scripts;
|
||||
private $scripts;
|
||||
|
||||
/**
|
||||
* Arbitrary extra data for consumption by scripts.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $extra;
|
||||
private $extra;
|
||||
|
||||
/**
|
||||
* A set of files that should be treated as binaries and made available into the bin-dir (from config).
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $Bin;
|
||||
private $bin;
|
||||
|
||||
/**
|
||||
* A set of options for creating package archives.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $archive;
|
||||
private $archive;
|
||||
|
||||
/**
|
||||
* Indicates whether this package has been abandoned.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $abandoned;
|
||||
private $abandoned;
|
||||
|
||||
/**
|
||||
* A list of regex patterns of branch names that are
|
||||
|
@ -282,16 +282,498 @@
|
|||
*
|
||||
* @var array|null
|
||||
*/
|
||||
public $non_feature_branches;
|
||||
private $non_feature_branches;
|
||||
|
||||
/**
|
||||
* Public Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = ComposerPackageTypes::LIBRARY;
|
||||
$this->minimum_stability = ComposerStabilityTypes::STABLE;
|
||||
$this->PreferStable = false;
|
||||
$this->abandoned = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription(): string
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $description
|
||||
*/
|
||||
public function setDescription(string $description): void
|
||||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getVersion(): ?string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $version
|
||||
*/
|
||||
public function setVersion(?string $version): void
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getKeywords(): array
|
||||
{
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $keywords
|
||||
*/
|
||||
public function setKeywords(array $keywords): void
|
||||
{
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getHomepage(): ?string
|
||||
{
|
||||
return $this->homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $homepage
|
||||
*/
|
||||
public function setHomepage(?string $homepage): void
|
||||
{
|
||||
$this->homepage = $homepage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getReadme(): ?string
|
||||
{
|
||||
return $this->readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $readme
|
||||
*/
|
||||
public function setReadme(?string $readme): void
|
||||
{
|
||||
$this->readme = $readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTime(): ?string
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $time
|
||||
*/
|
||||
public function setTime(?string $time): void
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getLicense(): array|string|null
|
||||
{
|
||||
return $this->license;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|string[]|null $license
|
||||
*/
|
||||
public function setLicense(array|string|null $license): void
|
||||
{
|
||||
$this->license = $license;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Author[]|null
|
||||
*/
|
||||
public function getAuthors(): ?array
|
||||
{
|
||||
return $this->authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Author[]|null $authors
|
||||
*/
|
||||
public function setAuthors(?array $authors): void
|
||||
{
|
||||
$this->authors = $authors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Support|null
|
||||
*/
|
||||
public function getSupport(): ?Support
|
||||
{
|
||||
return $this->support;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Support|null $support
|
||||
*/
|
||||
public function setSupport(?Support $support): void
|
||||
{
|
||||
$this->support = $support;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageLink[]|null
|
||||
*/
|
||||
public function getRequire(): ?array
|
||||
{
|
||||
return $this->require;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackageLink[]|null $require
|
||||
*/
|
||||
public function setRequire(?array $require): void
|
||||
{
|
||||
$this->require = $require;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageLink[]|null
|
||||
*/
|
||||
public function getRequireDev(): ?array
|
||||
{
|
||||
return $this->require_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackageLink[]|null $require_dev
|
||||
*/
|
||||
public function setRequireDev(?array $require_dev): void
|
||||
{
|
||||
$this->require_dev = $require_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageLink[]|null
|
||||
*/
|
||||
public function getConflict(): ?array
|
||||
{
|
||||
return $this->conflict;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackageLink[]|null $conflict
|
||||
*/
|
||||
public function setConflict(?array $conflict): void
|
||||
{
|
||||
$this->conflict = $conflict;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageLink[]|null
|
||||
*/
|
||||
public function getReplace(): ?array
|
||||
{
|
||||
return $this->replace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackageLink[]|null $replace
|
||||
*/
|
||||
public function setReplace(?array $replace): void
|
||||
{
|
||||
$this->replace = $replace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PackageLink[]|null
|
||||
*/
|
||||
public function getProvide(): ?array
|
||||
{
|
||||
return $this->provide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PackageLink[]|null $provide
|
||||
*/
|
||||
public function setProvide(?array $provide): void
|
||||
{
|
||||
$this->provide = $provide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Suggestion[]|null
|
||||
*/
|
||||
public function getSuggest(): ?array
|
||||
{
|
||||
return $this->suggest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Suggestion[]|null $suggest
|
||||
*/
|
||||
public function setSuggest(?array $suggest): void
|
||||
{
|
||||
$this->suggest = $suggest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Autoloader|null
|
||||
*/
|
||||
public function getAutoload(): ?Autoloader
|
||||
{
|
||||
return $this->autoload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Autoloader|null $autoload
|
||||
*/
|
||||
public function setAutoload(?Autoloader $autoload): void
|
||||
{
|
||||
$this->autoload = $autoload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Autoloader|null
|
||||
*/
|
||||
public function getAutoloadDev(): ?Autoloader
|
||||
{
|
||||
return $this->autoload_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Autoloader|null $autoload_dev
|
||||
*/
|
||||
public function setAutoloadDev(?Autoloader $autoload_dev): void
|
||||
{
|
||||
$this->autoload_dev = $autoload_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function getIncludePath(): ?array
|
||||
{
|
||||
return $this->include_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]|null $include_path
|
||||
*/
|
||||
public function setIncludePath(?array $include_path): void
|
||||
{
|
||||
$this->include_path = $include_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTargetDirectory(): ?string
|
||||
{
|
||||
return $this->target_directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $target_directory
|
||||
*/
|
||||
public function setTargetDirectory(?string $target_directory): void
|
||||
{
|
||||
$this->target_directory = $target_directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ComposerPackageTypes|string|null
|
||||
*/
|
||||
public function getMinimumStability(): ComposerPackageTypes|string|null
|
||||
{
|
||||
return $this->minimum_stability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ComposerPackageTypes|string|null $minimum_stability
|
||||
*/
|
||||
public function setMinimumStability(ComposerPackageTypes|string|null $minimum_stability): void
|
||||
{
|
||||
$this->minimum_stability = $minimum_stability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getRepositories(): ?array
|
||||
{
|
||||
return $this->repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $repositories
|
||||
*/
|
||||
public function setRepositories(?array $repositories): void
|
||||
{
|
||||
$this->repositories = $repositories;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getConfiguration(): ?array
|
||||
{
|
||||
return $this->configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $configuration
|
||||
*/
|
||||
public function setConfiguration(?array $configuration): void
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getScripts(): ?array
|
||||
{
|
||||
return $this->scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $scripts
|
||||
*/
|
||||
public function setScripts(?array $scripts): void
|
||||
{
|
||||
$this->scripts = $scripts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getExtra(): ?array
|
||||
{
|
||||
return $this->extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $extra
|
||||
*/
|
||||
public function setExtra(?array $extra): void
|
||||
{
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getBin(): ?array
|
||||
{
|
||||
return $this->bin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $bin
|
||||
*/
|
||||
public function setBin(?array $bin): void
|
||||
{
|
||||
$this->bin = $bin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getArchive(): ?array
|
||||
{
|
||||
return $this->archive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $archive
|
||||
*/
|
||||
public function setArchive(?array $archive): void
|
||||
{
|
||||
$this->archive = $archive;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAbandoned(): bool
|
||||
{
|
||||
return $this->abandoned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $abandoned
|
||||
*/
|
||||
public function setAbandoned(bool $abandoned): void
|
||||
{
|
||||
$this->abandoned = $abandoned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getNonFeatureBranches(): ?array
|
||||
{
|
||||
return $this->non_feature_branches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $non_feature_branches
|
||||
*/
|
||||
public function setNonFeatureBranches(?array $non_feature_branches): void
|
||||
{
|
||||
$this->non_feature_branches = $non_feature_branches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
|
@ -396,7 +878,7 @@
|
|||
'config' => $this->configuration,
|
||||
'scripts' => $this->scripts,
|
||||
'extra' => $this->extra,
|
||||
'bin' => $this->Bin,
|
||||
'bin' => $this->bin,
|
||||
'archive' => $this->archive,
|
||||
'abandoned' => $this->abandoned,
|
||||
'non-feature-branches' => $this->non_feature_branches
|
||||
|
@ -567,7 +1049,7 @@
|
|||
|
||||
if(isset($data['bin']))
|
||||
{
|
||||
$object->Bin = $data['bin'];
|
||||
$object->bin = $data['bin'];
|
||||
}
|
||||
|
||||
if(isset($data['archive']))
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
|
@ -29,62 +29,62 @@
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $Readme;
|
||||
private $readme;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $ContentHash;
|
||||
private $content_hash;
|
||||
|
||||
/**
|
||||
* @var ComposerJson[]|null
|
||||
*/
|
||||
public $Packages;
|
||||
private $packages;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $PackagesDev;
|
||||
private $packages_dev;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $Aliases;
|
||||
private $aliases;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $MinimumStability;
|
||||
private $minimum_stability;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $StabilityFlags;
|
||||
private $stability_flags;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $PreferStable;
|
||||
private $prefer_stable;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
public $PreferLowest;
|
||||
private $prefer_lowest;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $Platform;
|
||||
private $platform;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
public $PlatformDev;
|
||||
private $platform_dev;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
public $PluginApiVersion;
|
||||
private $plugin_api_version;
|
||||
|
||||
/**
|
||||
* Returns an existing package from the lock file
|
||||
|
@ -94,9 +94,9 @@
|
|||
*/
|
||||
public function getPackage(string $name): ?ComposerJson
|
||||
{
|
||||
foreach($this->Packages as $package)
|
||||
foreach($this->packages as $package)
|
||||
{
|
||||
if($package->name === $name)
|
||||
if($package->getName() === $name)
|
||||
{
|
||||
return $package;
|
||||
}
|
||||
|
@ -105,6 +105,198 @@
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReadme(): string
|
||||
{
|
||||
return $this->readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $readme
|
||||
*/
|
||||
public function setReadme(string $readme): void
|
||||
{
|
||||
$this->readme = $readme;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContentHash(): string
|
||||
{
|
||||
return $this->content_hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content_hash
|
||||
*/
|
||||
public function setContentHash(string $content_hash): void
|
||||
{
|
||||
$this->content_hash = $content_hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ComposerJson[]|null
|
||||
*/
|
||||
public function getPackages(): ?array
|
||||
{
|
||||
return $this->packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ComposerJson[]|null $packages
|
||||
*/
|
||||
public function setPackages(?array $packages): void
|
||||
{
|
||||
$this->packages = $packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPackagesDev(): ?array
|
||||
{
|
||||
return $this->packages_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $packages_dev
|
||||
*/
|
||||
public function setPackagesDev(?array $packages_dev): void
|
||||
{
|
||||
$this->packages_dev = $packages_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAliases(): ?array
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $aliases
|
||||
*/
|
||||
public function setAliases(?array $aliases): void
|
||||
{
|
||||
$this->aliases = $aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMinimumStability(): ?string
|
||||
{
|
||||
return $this->minimum_stability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $minimum_stability
|
||||
*/
|
||||
public function setMinimumStability(?string $minimum_stability): void
|
||||
{
|
||||
$this->minimum_stability = $minimum_stability;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getStabilityFlags(): ?array
|
||||
{
|
||||
return $this->stability_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $stability_flags
|
||||
*/
|
||||
public function setStabilityFlags(?array $stability_flags): void
|
||||
{
|
||||
$this->stability_flags = $stability_flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPreferStable(): bool
|
||||
{
|
||||
return $this->prefer_stable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $prefer_stable
|
||||
*/
|
||||
public function setPreferStable(bool $prefer_stable): void
|
||||
{
|
||||
$this->prefer_stable = $prefer_stable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPreferLowest(): bool
|
||||
{
|
||||
return $this->prefer_lowest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $prefer_lowest
|
||||
*/
|
||||
public function setPreferLowest(bool $prefer_lowest): void
|
||||
{
|
||||
$this->prefer_lowest = $prefer_lowest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPlatform(): ?array
|
||||
{
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $platform
|
||||
*/
|
||||
public function setPlatform(?array $platform): void
|
||||
{
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|null
|
||||
*/
|
||||
public function getPlatformDev(): ?array
|
||||
{
|
||||
return $this->platform_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|null $platform_dev
|
||||
*/
|
||||
public function setPlatformDev(?array $platform_dev): void
|
||||
{
|
||||
$this->platform_dev = $platform_dev;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPluginApiVersion(): ?string
|
||||
{
|
||||
return $this->plugin_api_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $plugin_api_version
|
||||
*/
|
||||
public function setPluginApiVersion(?string $plugin_api_version): void
|
||||
{
|
||||
$this->plugin_api_version = $plugin_api_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
|
@ -113,26 +305,26 @@
|
|||
public function toArray(): array
|
||||
{
|
||||
$_packages = [];
|
||||
if($this->Packages !== null)
|
||||
if($this->packages !== null)
|
||||
{
|
||||
foreach($this->Packages as $package)
|
||||
foreach($this->packages as $package)
|
||||
{
|
||||
$_packages[] = $package->toArray();
|
||||
}
|
||||
}
|
||||
return [
|
||||
'_readme' => $this->Readme,
|
||||
'content-hash' => $this->ContentHash,
|
||||
'_readme' => $this->readme,
|
||||
'content-hash' => $this->content_hash,
|
||||
'packages' => $_packages,
|
||||
'packages-dev' => $this->PackagesDev,
|
||||
'aliases' => $this->Aliases,
|
||||
'minimum-stability' => $this->MinimumStability,
|
||||
'stability-flags' => $this->StabilityFlags,
|
||||
'prefer-stable' => $this->PreferStable,
|
||||
'prefer-lowest' => $this->PreferLowest,
|
||||
'platform' => $this->Platform,
|
||||
'platform-dev' => $this->PlatformDev,
|
||||
'plugin-api-version' => $this->PluginApiVersion,
|
||||
'packages-dev' => $this->packages_dev,
|
||||
'aliases' => $this->aliases,
|
||||
'minimum-stability' => $this->minimum_stability,
|
||||
'stability-flags' => $this->stability_flags,
|
||||
'prefer-stable' => $this->prefer_stable,
|
||||
'prefer-lowest' => $this->prefer_lowest,
|
||||
'platform' => $this->platform,
|
||||
'platform-dev' => $this->platform_dev,
|
||||
'plugin-api-version' => $this->plugin_api_version,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -146,25 +338,25 @@
|
|||
{
|
||||
$object = new self();
|
||||
|
||||
$object->Readme = $data['_readme'];
|
||||
$object->ContentHash = $data['content-hash'];
|
||||
$object->Packages = [];
|
||||
$object->readme = $data['_readme'];
|
||||
$object->content_hash = $data['content-hash'];
|
||||
$object->packages = [];
|
||||
if($data['packages'] !== null)
|
||||
{
|
||||
foreach($data['packages'] as $package)
|
||||
{
|
||||
$object->Packages[] = ComposerJson::fromArray($package);
|
||||
$object->packages[] = ComposerJson::fromArray($package);
|
||||
}
|
||||
}
|
||||
$object->PackagesDev = $data['packages-dev'];
|
||||
$object->Aliases = $data['aliases'];
|
||||
$object->MinimumStability = $data['minimum-stability'];
|
||||
$object->StabilityFlags = $data['stability-flags'];
|
||||
$object->PreferStable = $data['prefer-stable'];
|
||||
$object->PreferLowest = $data['prefer-lowest'];
|
||||
$object->Platform = $data['platform'];
|
||||
$object->PlatformDev = $data['platform-dev'];
|
||||
$object->PluginApiVersion = $data['plugin-api-version'];
|
||||
$object->packages_dev = $data['packages-dev'];
|
||||
$object->aliases = $data['aliases'];
|
||||
$object->minimum_stability = $data['minimum-stability'];
|
||||
$object->stability_flags = $data['stability-flags'];
|
||||
$object->prefer_stable = $data['prefer-stable'];
|
||||
$object->prefer_lowest = $data['prefer-lowest'];
|
||||
$object->platform = $data['platform'];
|
||||
$object->platform_dev = $data['platform-dev'];
|
||||
$object->plugin_api_version = $data['plugin-api-version'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
|
@ -37,28 +37,92 @@
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* The type of service NCC should use with this source (gitlab, github, etc...).
|
||||
*
|
||||
* @var string|DefinedRemoteSourceType
|
||||
*/
|
||||
public $type;
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* The host of the service NCC should use with this source (gitlab.com, github.com, git.example.com:8080 etc...).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $host;
|
||||
private $host;
|
||||
|
||||
/**
|
||||
* If SSL should be used when connecting to the service
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $ssl;
|
||||
private $ssl;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name): void
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DefinedRemoteSourceType|string
|
||||
*/
|
||||
public function getType(): DefinedRemoteSourceType|string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DefinedRemoteSourceType|string $type
|
||||
*/
|
||||
public function setType(DefinedRemoteSourceType|string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost(): string
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
*/
|
||||
public function setHost(string $host): void
|
||||
{
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSsl(): bool
|
||||
{
|
||||
return $this->ssl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $ssl
|
||||
*/
|
||||
public function setSsl(bool $ssl): void
|
||||
{
|
||||
$this->ssl = $ssl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
|
|
|
@ -1,100 +1,193 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace ncc\Objects;
|
||||
|
||||
use JsonException;
|
||||
use ncc\Enums\HttpRequestType;
|
||||
use ncc\Interfaces\SerializableObjectInterface;
|
||||
use RuntimeException;
|
||||
|
||||
class HttpRequest
|
||||
class HttpRequest implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* The HTTP request type.
|
||||
*
|
||||
* @var string|HttpRequestType
|
||||
*/
|
||||
public $Type;
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* The URL to send the request to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $Url;
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* The headers to send with the request.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Headers;
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* The body to send with the request.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
public $Body;
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* The authentication username or password to send with the request.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
public $Authentication;
|
||||
private $authentication;
|
||||
|
||||
/**
|
||||
* An array of curl options to set
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Options;
|
||||
private $options;
|
||||
|
||||
/**
|
||||
* Public Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->Type = HttpRequestType::GET;
|
||||
$this->Body = null;
|
||||
$this->Headers = [
|
||||
$this->type = HttpRequestType::GET;
|
||||
$this->options = [];
|
||||
$this->headers = [
|
||||
'User-Agent: ncc/1.0'
|
||||
];
|
||||
$this->Options = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object.
|
||||
*
|
||||
* @return HttpRequestType|string
|
||||
*/
|
||||
public function getType(): HttpRequestType|string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param HttpRequestType|string $type
|
||||
*/
|
||||
public function setType(HttpRequestType|string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl(string $url): void
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string[] $headers
|
||||
*/
|
||||
public function setHeaders(array $headers): void
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $header
|
||||
* @return void
|
||||
*/
|
||||
public function addHeader(string $header): void
|
||||
{
|
||||
$this->headers[] = $header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getBody(): ?string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $body
|
||||
*/
|
||||
public function setBody(?string $body): void
|
||||
{
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string
|
||||
*/
|
||||
public function getAuthentication(): array|string
|
||||
{
|
||||
return $this->authentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $authentication
|
||||
*/
|
||||
public function setAuthentication(array|string $authentication): void
|
||||
{
|
||||
$this->authentication = $authentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
public function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->Type,
|
||||
'url' => $this->Url,
|
||||
'headers' => $this->Headers,
|
||||
'body' => $this->Body,
|
||||
'authentication' => $this->Authentication,
|
||||
'options' => $this->Options
|
||||
];
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*/
|
||||
public function setOptions(array $options): void
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,24 +198,50 @@
|
|||
*/
|
||||
public function requestHash(): string
|
||||
{
|
||||
return hash('sha1', json_encode($this->toArray()));
|
||||
try
|
||||
{
|
||||
return hash('sha1', json_encode($this->toArray(), JSON_THROW_ON_ERROR));
|
||||
}
|
||||
catch(JsonException $e)
|
||||
{
|
||||
throw new RuntimeException(sprintf('Failed to hash request: %s', $e->getMessage()), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'type' => $this->type,
|
||||
'url' => $this->url,
|
||||
'headers' => $this->headers,
|
||||
'body' => $this->body,
|
||||
'authentication' => $this->authentication,
|
||||
'options' => $this->options
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new HttpRequest object from an array representation.
|
||||
*
|
||||
* @param array $data
|
||||
* @return static
|
||||
* @return HttpRequest
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
public static function fromArray(array $data): HttpRequest
|
||||
{
|
||||
$request = new self();
|
||||
$request->Type = $data['type'];
|
||||
$request->Url = $data['url'];
|
||||
$request->Headers = $data['headers'];
|
||||
$request->Body = $data['body'];
|
||||
$request->Authentication = $data['authentication'];
|
||||
$request->Options = $data['options'];
|
||||
|
||||
$request->type = $data['type'];
|
||||
$request->url = $data['url'];
|
||||
$request->headers = $data['headers'];
|
||||
$request->body = $data['body'];
|
||||
$request->authentication = $data['authentication'];
|
||||
$request->options = $data['options'];
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
|
@ -1,57 +1,110 @@
|
|||
<?php
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Nosial 2022-2023, all rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
|
||||
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace ncc\Objects;
|
||||
|
||||
class HttpResponse
|
||||
use ncc\Interfaces\SerializableObjectInterface;
|
||||
|
||||
class HttpResponse implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* The HTTP status code.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $StatusCode;
|
||||
private $status_code;
|
||||
|
||||
/**
|
||||
* The headers returned by the server.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $Headers;
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* The body returned by the server.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $Body;
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* HttpResponse constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->StatusCode = 0;
|
||||
$this->Headers = [];
|
||||
$this->Body = '';
|
||||
$this->status_code = 0;
|
||||
$this->headers = [];
|
||||
$this->body = (string)null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode(): int
|
||||
{
|
||||
return $this->status_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $status_code
|
||||
*/
|
||||
public function setStatusCode(int $status_code): void
|
||||
{
|
||||
$this->status_code = $status_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders(): array
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headers
|
||||
*/
|
||||
public function setHeaders(array $headers): void
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBody(): string
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $body
|
||||
*/
|
||||
public function setBody(string $body): void
|
||||
{
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,9 +115,23 @@
|
|||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'status_code' => $this->StatusCode,
|
||||
'headers' => $this->Headers,
|
||||
'body' => $this->Body
|
||||
'status_code' => $this->status_code,
|
||||
'headers' => $this->headers,
|
||||
'body' => $this->body
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): HttpResponse
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->status_code = $data['status_code'];
|
||||
$object->headers = $data['headers'];
|
||||
$object->body = $data['body'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
|
@ -203,9 +203,9 @@
|
|||
|
||||
foreach($input as $optionsSection)
|
||||
{
|
||||
if(count($optionsSection->Parameters) > 0)
|
||||
if(count($optionsSection->getParameters()) > 0)
|
||||
{
|
||||
foreach($optionsSection->Parameters as $parameter)
|
||||
foreach($optionsSection->getParameters() as $parameter)
|
||||
{
|
||||
if($current_count < strlen($parameter))
|
||||
{
|
||||
|
@ -572,7 +572,7 @@
|
|||
switch ($entry->getPassword()?->getAuthenticationType())
|
||||
{
|
||||
case AuthenticationType::ACCESS_TOKEN:
|
||||
$http_request->Headers[] = "Authorization: Bearer " . $entry->getPassword();
|
||||
$http_request->addHeader("Authorization: Bearer " . $entry->getPassword());
|
||||
break;
|
||||
|
||||
case AuthenticationType::USERNAME_PASSWORD:
|
||||
|
@ -582,8 +582,8 @@
|
|||
|
||||
if($expect_json)
|
||||
{
|
||||
$http_request->Headers[] = "Accept: application/json";
|
||||
$http_request->Headers[] = "Content-Type: application/json";
|
||||
$http_request->addHeader("Accept: application/json");
|
||||
$http_request->addHeader("Content-Type: application/json");
|
||||
}
|
||||
|
||||
return $http_request;
|
||||
|
@ -607,8 +607,8 @@
|
|||
|
||||
$out_path = self::getTmpDir() . "/" . basename($url);
|
||||
$http_request = new HttpRequest();
|
||||
$http_request->Url = $url;
|
||||
$http_request->Type = HttpRequestType::GET;
|
||||
$http_request->setUrl($url);
|
||||
$http_request->setType(HttpRequestType::GET);
|
||||
$http_request = self::prepareGitServiceRequest($http_request, $entry, false);
|
||||
|
||||
Console::out('Downloading file ' . $url);
|
||||
|
@ -790,7 +790,7 @@
|
|||
{
|
||||
$results = new RepositoryQueryResults();
|
||||
|
||||
switch($definedRemoteSource->type)
|
||||
switch($definedRemoteSource->getType())
|
||||
{
|
||||
case DefinedRemoteSourceType::GITHUB:
|
||||
$source = GithubService::class;
|
||||
|
@ -807,7 +807,7 @@
|
|||
// Check if the specified version is a release
|
||||
try
|
||||
{
|
||||
Console::outVerbose(sprintf('Attempting to fetch source code from %s', $definedRemoteSource->host));
|
||||
Console::outVerbose(sprintf('Attempting to fetch source code from %s', $definedRemoteSource->getHost()));
|
||||
$release_results = $source::getRelease($packageInput, $definedRemoteSource, $entry);
|
||||
}
|
||||
catch(Exception $e)
|
||||
|
|
Loading…
Add table
Reference in a new issue