for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace MarkSitko\LaravelUnsplash\Http;
use Exception;
use GuzzleHttp\Client;
class HttpClient
{
const API_URL = 'https://api.unsplash.com/';
protected $client;
private $accessKey;
/**
* Creates a new instance of HttpClient
* @return MarkSitko\LaravelUnsplash\Http\HttpClient
@return
Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.
Please refer to the PHP core documentation on constructors.
*/
public function __construct()
$this->initalizeConfiguration()
->createClient();
return $this;
}
* Initalize and store configuration values in class properties
private function initalizeConfiguration()
$this->accessKey = config('unsplash.access_key');
if ( !$this->accessKey ) {
throw new Exception('A Unsplash-API access key must be provided');
* Instantiate the GuzzleHttp Client
private function createClient()
$this->client = new Client([
'base_uri' => self::API_URL,
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => "Client-ID {$this->accessKey}",
],
]);
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.