Skip to content

Commit b2452e0

Browse files
committed
Document new function
1 parent e050b6a commit b2452e0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/Package_Command.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,8 @@ private function get_package_by_shortened_identifier( $package_name, $insecure =
836836
$options = [ 'insecure' => $insecure ];
837837

838838
// Check if the package exists on Packagist.
839-
$response = $this->get_from_packagist( $package_name, $options );
839+
$url = $this->get_packagist_url( $package_name, $options );
840+
$response = Utils\http_request( 'GET', $url, null, [], $options );
840841
if ( 20 === (int) substr( $response->status_code, 0, 2 ) ) {
841842
return $package_name;
842843
}
@@ -863,16 +864,18 @@ private function get_package_by_shortened_identifier( $package_name, $insecure =
863864
return false;
864865
}
865866

866-
private function get_from_packagist( $package_name, $options ) {
867+
/**
868+
* Gets the correct packagist URL.
869+
*/
870+
private function get_packagist_url( $package_name, $options ) {
867871
$url = "https://repo.packagist.org/p/{$package_name}.json";
868872
$response = Utils\http_request( 'GET', $url, null, [], $options );
869873

870874
if ( 20 === (int) substr( $response->status_code, 0, 2 ) ) {
871-
return $response;
875+
return $url;
872876
}
873877

874-
$url = "https://repo.packagist.org/p2/{$package_name}.json";
875-
return Utils\http_request( 'GET', $url, null, [], $options );
878+
return "https://repo.packagist.org/p2/{$package_name}.json";
876879
}
877880

878881
/**

0 commit comments

Comments
 (0)