File: /home/boxelikax/public_html/demoltec.com/knplabs.zip
PK ҽ]U�1�$ $ * packagist-api/src/Packagist/Api/Client.phpnu �[��� <?php
namespace Packagist\Api;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\ClientInterface;
use Packagist\Api\Result\Factory;
/**
* Packagist Api
*
* @since 1.0
* @api
*/
class Client
{
/**
* HTTP client
*
* @var ClientInterface|null
*/
protected $httpClient;
/**
* DataObject Factory
*
* @var Factory|null
*/
protected $resultFactory;
/**
* Packagist url
*
* @var string|null
*/
protected $packagistUrl;
/**
* Constructor.
*
* @since 1.1 Added the $packagistUrl argument
* @since 1.0
*
* @param ClientInterface|null $httpClient HTTP client
* @param Factory|null $resultFactory DataObject Factory
* @param string|null $packagistUrl Packagist url
*/
public function __construct(
ClientInterface $httpClient = null,
Factory $resultFactory = null,
$packagistUrl = "https://packagist.org"
) {
$this->httpClient = $httpClient;
$this->resultFactory = $resultFactory;
$this->packagistUrl = $packagistUrl;
}
/**
* Search packages
*
* Available filters :
*
* * vendor: vendor of package (require or require-dev in composer.json)
* * type: type of package (type in composer.json)
* * tags: tags of package (keywords in composer.json)
*
* @since 1.0
*
* @param string $query Name of package
* @param array $filters An array of filters
* @param int $limit Pages to limit results (0 = all pages)
*
* @return array The results
*/
public function search($query, array $filters = array(), int $limit = 0)
{
$results = $response = array();
$filters['q'] = $query;
$url = '/search.json?' . http_build_query($filters);
$response['next'] = $this->url($url);
do {
$response = $this->request($response['next']);
$response = $this->parse($response);
$createResult = $this->create($response);
if (!is_array($createResult)) {
$createResult = [$createResult];
}
$results = array_merge($results, $createResult);
if (isset($response['next'])) {
parse_str(parse_url($response['next'], PHP_URL_QUERY), $parse);
}
} while (isset($response['next']) && (0 === $limit || $parse['page'] <= $limit));
return $results;
}
/**
* Retrieve full package information
*
* @since 1.0
*
* @param string $package Full qualified name ex : myname/mypackage
*
* @return array|\Packagist\Api\Result\Package A package instance or array of packages
*/
public function get($package)
{
return $this->respond(sprintf($this->url('/packages/%s.json'), $package));
}
/**
* Search packages
*
* Available filters :
*
* * vendor: vendor of package (require or require-dev in composer.json)
* * type: type of package (type in composer.json)
* * tags: tags of package (keywords in composer.json)
*
* @since 1.0
*
* @param array $filters An array of filters
*
* @return array|\Packagist\Api\Result\Package The results, or single result
*/
public function all(array $filters = array())
{
$url = '/packages/list.json';
if ($filters) {
$url .= '?' . http_build_query($filters);
}
return $this->respond($this->url($url));
}
/**
* Popular packages
*
* @since 1.3
*
* @param int $total
* @return array The results
*/
public function popular($total)
{
$results = $response = array();
$url = '/explore/popular.json?' . http_build_query(array('page' => 1));
$response['next'] = $this->url($url);
do {
$response = $this->request($response['next']);
$response = $this->parse($response);
$createResult = $this->create($response);
if (!is_array($createResult)) {
$createResult = [$createResult];
}
$results = array_merge($results, $createResult);
} while (count($results) < $total && isset($response['next']));
return array_slice($results, 0, $total);
}
/**
* Assemble the packagist URL with the route
*
* @param string $route API Route that we want to achieve
*
* @return string Fully qualified URL
*/
protected function url($route)
{
return $this->packagistUrl . $route;
}
/**
* Execute the url request and parse the response
*
* @param string $url
*
* @return array|\Packagist\Api\Result\Package
*/
protected function respond($url)
{
$response = $this->request($url);
$response = $this->parse($response);
return $this->create($response);
}
/**
* Execute the url request
*
* @param string $url
*
* @return \Psr\Http\Message\StreamInterface
*/
protected function request($url)
{
if (null === $this->httpClient) {
$this->httpClient = new HttpClient();
}
return $this->httpClient
->request('GET', $url)
->getBody();
}
/**
* Decode json
*
* @param string $data Json string
*
* @return array Json decode
*/
protected function parse($data)
{
return json_decode($data, true);
}
/**
* Hydrate the knowing type depending on passed data
*
* @param array $data
*
* @return array|\Packagist\Api\Result\Package
*/
protected function create(array $data)
{
if (null === $this->resultFactory) {
$this->resultFactory = new Factory();
}
return $this->resultFactory->create($data);
}
/**
* Change the packagist URL
*
* @since 1.1
*
* @param string $packagistUrl URL
*/
public function setPackagistUrl($packagistUrl)
{
$this->packagistUrl = $packagistUrl;
}
/**
* Return the actual packagist URL
*
* @since 1.1
*
* @return string|null URL
*/
public function getPackagistUrl()
{
return $this->packagistUrl;
}
}
PK ҽ]
�L��
�
2 packagist-api/src/Packagist/Api/Result/Factory.phpnu �[��� <?php
namespace Packagist\Api\Result;
use InvalidArgumentException;
/**
* Map raw data from website api to has a know type
*
* @since 1.0
*/
class Factory
{
/**
* Analyse the data and transform to a known type
*
* @param array $data
* @throws InvalidArgumentException
*
* @return array|Package
*/
public function create(array $data)
{
if (isset($data['results'])) {
return $this->createSearchResults($data['results']);
}
if (isset($data['packages'])) {
return $this->createSearchResults($data['packages']);
}
if (isset($data['package'])) {
return $this->createPackageResults($data['package']);
}
if (isset($data['packageNames'])) {
return $data['packageNames'];
}
throw new InvalidArgumentException('Invalid input data.');
}
/**
* Create a collection of \Packagist\Api\Result\Result
* @param array $results
*
* @return array
*/
public function createSearchResults(array $results)
{
$created = array();
foreach ($results as $key => $result) {
$created[$key] = $this->createResult('Packagist\Api\Result\Result', $result);
}
return $created;
}
/**
* Parse array to \Packagist\Api\Result\Result
* @param array $package
*
* @return Package
*/
public function createPackageResults(array $package)
{
$created = array();
if (isset($package['maintainers']) && $package['maintainers']) {
foreach ($package['maintainers'] as $key => $maintainer) {
$package['maintainers'][$key] = $this->createResult(
'Packagist\Api\Result\Package\Maintainer',
$maintainer
);
}
}
if (isset($package['downloads']) && $package['downloads']) {
$package['downloads'] = $this->createResult(
'Packagist\Api\Result\Package\Downloads',
$package['downloads']
);
}
$package['description'] = (string) $package['description'] ?? '';
foreach ($package['versions'] as $branch => $version) {
if (isset($version['authors']) && $version['authors']) {
foreach ($version['authors'] as $key => $author) {
$version['authors'][$key] = $this->createResult('Packagist\Api\Result\Package\Author', $author);
}
}
if ($version['source']) {
$version['source'] = $this->createResult('Packagist\Api\Result\Package\Source', $version['source']);
}
if (isset($version['dist']) && $version['dist']) {
$version['dist'] = $this->createResult('Packagist\Api\Result\Package\Dist', $version['dist']);
}
$package['versions'][$branch] = $this->createResult('Packagist\Api\Result\Package\Version', $version);
}
$created = new Package();
$created->fromArray($package);
return $created;
}
/**
* Dynamically create DataObject of type $class and hydrate
*
* @param string $class DataObject class
* @param array $data Array of data
*
* @return mixed DataObject $class hydrated
*/
protected function createResult($class, array $data)
{
$result = new $class();
$result->fromArray($data);
return $result;
}
}
PK ҽ]��}�^
^
2 packagist-api/src/Packagist/Api/Result/Package.phpnu �[��� <?php
namespace Packagist\Api\Result;
class Package extends AbstractResult
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $description;
/**
* @var string
*/
protected $time;
/**
* @var Package\Maintainer[]
*/
protected $maintainers;
/**
* @var Package\Version[]
*/
protected $versions;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $repository;
/**
* @var Package\Downloads
*/
protected $downloads;
/**
* @var string
*/
protected $favers;
/**
* @var bool|string
*/
protected $abandoned = false;
/**
* @var integer
*/
protected $suggesters = 0;
/**
* @var integer
*/
protected $dependents = 0;
/**
* @var integer
*/
protected $githubStars = 0;
/**
* @var integer
*/
protected $githubForks = 0;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return string
*/
public function getTime()
{
return $this->time;
}
/**
* @return Package\Maintainer[]
*/
public function getMaintainers()
{
return $this->maintainers;
}
/**
* @return Package\Version[]
*/
public function getVersions()
{
return $this->versions;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getRepository()
{
return $this->repository;
}
/**
* @return Package\Downloads
*/
public function getDownloads()
{
return $this->downloads;
}
/**
* @return string
*/
public function getFavers()
{
return $this->favers;
}
/**
* @return bool
*/
public function isAbandoned()
{
return (bool) $this->abandoned;
}
/**
* Gets the package name to use as a replacement if this package is abandoned
*
* @return string|null
*/
public function getReplacementPackage(): ?string
{
// The Packagist API will either return a boolean, or a string value for `abandoned`. It will be a boolean
// if no replacement package was provided when the package was marked as abandoned in Packagist, or it will be
// a string containing the replacement package name to use if one was provided.
// @see https://github.com/KnpLabs/packagist-api/pull/56#discussion_r306426997
if (is_string($this->abandoned)) {
return $this->abandoned;
}
return null;
}
/**
* @return integer
*/
public function getSuggesters()
{
return $this->suggesters;
}
/**
* @return integer
*/
public function getDependents()
{
return $this->dependents;
}
/**
* @return integer
*/
public function getGithubStars()
{
return $this->githubStars;
}
/**
* @return integer
*/
public function getGithubForks()
{
return $this->githubForks;
}
}
PK ҽ]�l^l l 1 packagist-api/src/Packagist/Api/Result/Result.phpnu �[��� <?php
namespace Packagist\Api\Result;
class Result extends AbstractResult
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $description;
/**
* @var string
*/
protected $url;
/**
* @var string
*/
protected $downloads;
/**
* @var string
*/
protected $favers;
/**
* @var string
*/
protected $repository;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @return string
*/
public function getDownloads()
{
return $this->downloads;
}
/**
* @return string
*/
public function getFavers()
{
return $this->favers;
}
/**
* @return string
*/
public function getRepository()
{
return $this->repository;
}
}
PK ҽ]<�ϳf f : packagist-api/src/Packagist/Api/Result/Package/Version.phpnu �[��� <?php
namespace Packagist\Api\Result\Package;
use Packagist\Api\Result\AbstractResult;
class Version extends AbstractResult
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $description;
/**
* @var array
*/
protected $keywords;
/**
* @var string
*/
protected $homepage;
/**
* @var string
*/
protected $version;
/**
* @var string
*/
protected $versionNormalized;
/**
* @var string
*/
protected $license;
/**
* @var array
*/
protected $authors;
/**
* @var Source
*/
protected $source;
/**
* @var Dist
*/
protected $dist;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $time;
/**
* @var array
*/
protected $autoload;
/**
* @var array
*/
protected $extra;
/**
* @var array
*/
protected $require;
/**
* @var array
*/
protected $requireDev;
/**
* @var string
*/
protected $conflict;
/**
* @var string
*/
protected $provide;
/**
* @var string
*/
protected $replace;
/**
* @var string
*/
protected $bin;
/**
* @var array
*/
protected $suggest;
/**
* @var bool|string
*/
protected $abandoned = false;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return array
*/
public function getKeywords()
{
return $this->keywords;
}
/**
* @return string
*/
public function getHomepage()
{
return $this->homepage;
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @return string
*/
public function getVersionNormalized()
{
return $this->versionNormalized;
}
/**
* @return string
*/
public function getLicense()
{
return $this->license;
}
/**
* @return array
*/
public function getAuthors()
{
return $this->authors;
}
/**
* @return Source
*/
public function getSource()
{
return $this->source;
}
/**
* @return Dist
*/
public function getDist()
{
return $this->dist;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getTime()
{
return $this->time;
}
/**
* @return array
*/
public function getAutoload()
{
return $this->autoload;
}
/**
* @return array
*/
public function getExtra()
{
return $this->extra;
}
/**
* @return array
*/
public function getRequire()
{
return $this->require;
}
/**
* @return array
*/
public function getRequireDev()
{
return $this->requireDev;
}
/**
* @return string
*/
public function getConflict()
{
return $this->conflict;
}
/**
* @return string
*/
public function getProvide()
{
return $this->provide;
}
/**
* @return string
*/
public function getReplace()
{
return $this->replace;
}
/**
* @return string
*/
public function getBin()
{
return $this->bin;
}
/**
* @return array
*/
public function getSuggest()
{
return $this->suggest;
}
/**
* @return bool
*/
public function isAbandoned()
{
return (bool) $this->abandoned;
}
/**
* Gets the package name to use as a replacement if this package is abandoned
*
* @return string|null
*/
public function getReplacementPackage(): ?string
{
// The Packagist API will either return a boolean, or a string value for `abandoned`. It will be a boolean
// if no replacement package was provided when the package was marked as abandoned in Packagist, or it will be
// a string containing the replacement package name to use if one was provided.
// @see https://github.com/KnpLabs/packagist-api/pull/56#discussion_r306426997
if (is_string($this->abandoned)) {
return $this->abandoned;
}
return null;
}
}
PK ҽ]8_�\� � 9 packagist-api/src/Packagist/Api/Result/Package/Author.phpnu �[��� <?php
namespace Packagist\Api\Result\Package;
class Author extends Maintainer
{
/**
* @var string
*/
protected $role;
/**
* @return string
*/
public function getRole()
{
return $this->role;
}
}
PK ҽ]���� 9 packagist-api/src/Packagist/Api/Result/Package/Source.phpnu �[��� <?php
namespace Packagist\Api\Result\Package;
use Packagist\Api\Result\AbstractResult;
class Source extends AbstractResult
{
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $url;
/**
* @var string
*/
protected $reference;
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @return string
*/
public function getReference()
{
return $this->reference;
}
}
PK ҽ]��R�� � = packagist-api/src/Packagist/Api/Result/Package/Maintainer.phpnu �[��� <?php
namespace Packagist\Api\Result\Package;
use Packagist\Api\Result\AbstractResult;
class Maintainer extends AbstractResult
{
/**
* @var string
*/
protected $name;
/**
* @var string
*/
protected $email;
/**
* @var string
*/
protected $homepage;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @return string
*/
public function getHomepage()
{
return $this->homepage;
}
}
PK ҽ]=�� � 7 packagist-api/src/Packagist/Api/Result/Package/Dist.phpnu �[��� <?php
namespace Packagist\Api\Result\Package;
class Dist extends Source
{
/**
* @var string
*/
protected $shasum;
/**
* @var string
*/
protected $type;
/**
* @var string
*/
protected $url;
/**
* @var string
*/
protected $reference;
/**
* @return string
*/
public function getShasum()
{
return $this->shasum;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* @return string
*/
public function getReference()
{
return $this->reference;
}
}
PK ҽ]��� <