PHP Classes

File: src/Generics/Client/HttpClientFactory.php

Recommend this page to a friend!
  Classes of Maik Greubel   PHP Generics   src/Generics/Client/HttpClientFactory.php   Download  
File: src/Generics/Client/HttpClientFactory.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change: Update of src/Generics/Client/HttpClientFactory.php
Date: 6 months ago
Size: 788 bytes
 

Contents

Class file image Download
<?php
/**
 * This file is part of the PHP Generics package.
 *
 * @package Generics
 */
namespace Generics\Client;

use
Generics\Socket\Url;
use
Generics\Streams\HttpStream;

/**
 * This class provides a factory for http(s) clients
 *
 * @author Maik Greubel <greubel@nkey.de>
 */
final class HttpClientFactory
{

    private function
__construct()
    {
       
// Nothing
   
}

   
/**
     * Create a new instance of Http(s) client for given url
     *
     * @param Url $url
     * The url to create a http(s) client instance for
     *
     * @return HttpStream
     */
   
public static function get(Url $url): HttpStream
   
{
        if (
$url->getScheme() === 'https') {
            return new
HttpsClient($url);
        }
        return new
HttpClient($url);
    }
}