src/Bandolier/Type/Paths.php
public static function fileGetContents(array $params = [])
    {
        /** @var string $toPath Path to get request from */
        /** @var array $clientParams parameters passed into client */
        /** @var \GuzzleHttp\Client $client */
        /** @var string $request_type request type */
        /** @var array $requestParams parameters to pass into request */
        /** @var string $request type of request */
        $parameters = new Collection();
        $parameters->addItems((array)Arrays::defaultAttributes([
            "toPath" => self::httpProtocol() . '://' . self::serverName() . '/',
            "clientParams" => [],
            "client" => "\\GuzzleHttp\\Client",
            "request" => "GET",
            "requestParams" => [],
        ], $params));

        $parameters->addItem(parse_url($parameters->getItem('toPath'), PHP_URL_SCHEME) . "://" . parse_url($parameters->getItem('toPath'), PHP_URL_HOST), 'base_uri');
        $parameters->setItem(array_merge($parameters->getItem('clientParams'), array('base_uri' => $parameters->getItem('base_uri'))), 'clientParams');
        if (is_string($parameters->getItem('client'))) {
            $client = $parameters->getItem('client');
            $parameters->setItem(new $client($parameters->getItem('clientParams')), 'client');
        }

        $path = substr($parameters->getItem('toPath'), strlen($parameters->getItem('base_uri')), strlen($parameters->getItem('toPath')));
        if (method_exists($parameters->getItem('client'), 'request')) {
            // For GuzzleHttp 6
            return $parameters->getItem('client')
                ->request($parameters->getItem('request'), $path, $parameters->getItem('requestParams'))
                ->getBody()
                ->getContents();
        } elseif (method_exists($parameters->getItem('client'), 'createRequest')) {
            // for GuzzleHttp 5.3
            $request = $parameters->getItem('client')
                ->createRequest($parameters->getItem('request'), $path, $parameters->getItem('requestParams'));
            return $parameters->getItem('client')->send($request)->getBody();
        } else {
          throw new FileGetContentsException('The client must be an instance of \\GuzzleHttp\\Client');
        }
    }
public static function fileGetContents(array $params = [])
    {
        /** @var string $toPath Path to get request from */
        /** @var array $clientParams parameters passed into client */
        /** @var \GuzzleHttp\Client $client */
        /** @var string $request_type request type */
        /** @var array $requestParams parameters to pass into request */
        /** @var string $request type of request */
        $parameters = new Collection();
        $parameters->addItems((array)Arrays::defaultAttributes([
            "toPath" => self::httpProtocol() . '://' . self::serverName() . '/',
            "clientParams" => [],
            "client" => "\\GuzzleHttp\\Client",
            "request" => "GET",
            "requestParams" => [],
        ], $params));

        $parameters->addItem(parse_url($parameters->getItem('toPath'), PHP_URL_SCHEME) . "://" . parse_url($parameters->getItem('toPath'), PHP_URL_HOST), 'base_uri');
        $parameters->setItem(array_merge($parameters->getItem('clientParams'), array('base_uri' => $parameters->getItem('base_uri'))), 'clientParams');
        if (is_string($parameters->getItem('client'))) {
            $client = $parameters->getItem('client');
            $parameters->setItem(new $client($parameters->getItem('clientParams')), 'client');
        }

        $path = substr($parameters->getItem('toPath'), strlen($parameters->getItem('base_uri')), strlen($parameters->getItem('toPath')));
        if (method_exists($parameters->getItem('client'), 'request')) {
            // For GuzzleHttp 6
            return $parameters->getItem('client')
                ->request($parameters->getItem('request'), $path, $parameters->getItem('requestParams'))
                ->getBody()
                ->getContents();
        } elseif (method_exists($parameters->getItem('client'), 'createRequest')) {
            // for GuzzleHttp 5.3
            $request = $parameters->getItem('client')
                ->createRequest($parameters->getItem('request'), $path, $parameters->getItem('requestParams'));
            return $parameters->getItem('client')->send($request)->getBody();
        } else {
          throw new FileGetContentsException('The client must be an instance of \\GuzzleHttp\\Client');
        }
    }
public static function fileGetContents ( array $ params = [ ] ) { /** @var string $toPath Path to get request from */ /** @var array $clientParams parameters passed into client */ /** @var \GuzzleHttp\Client $client */ /** @var string $request_type request type */ /** @var array $requestParams parameters to pass into request */ /** @var string $request type of request */ $ parameters = new Collection ( ) ; $ parameters -> addItems ( ( array ) Arrays :: defaultAttributes ( [ "toPath" => self :: httpProtocol ( ) . '://' . self :: serverName ( ) . '/' , "clientParams" => [ ] , "client" => "\\GuzzleHttp\\Client" , "request" => "GET" , "requestParams" => [ ] , ] , $ params ) ) ; $ parameters -> addItem ( parse_url ( $ parameters -> getItem ( 'toPath' ) , PHP_URL_SCHEME ) . "://" . parse_url ( $ parameters -> getItem ( 'toPath' ) , PHP_URL_HOST ) , 'base_uri' ) ; $ parameters -> setItem ( array_merge ( $ parameters -> getItem ( 'clientParams' ) , array ( 'base_uri' => $ parameters -> getItem ( 'base_uri' ) ) ) , 'clientParams' ) ; if ( is_string ( $ parameters -> getItem ( 'client' ) ) ) { $ client = $ parameters -> getItem ( 'client' ) ; $ parameters -> setItem ( new $ client ( $ parameters -> getItem ( 'clientParams' ) ) , 'client' ) ; } $ path = substr ( $ parameters -> getItem ( 'toPath' ) , strlen ( $ parameters -> getItem ( 'base_uri' ) ) , strlen ( $ parameters -> getItem ( 'toPath' ) ) ) ; if ( method_exists ( $ parameters -> getItem ( 'client' ) , 'request' ) ) { // For GuzzleHttp 6 return $ parameters -> getItem ( 'client' ) -> request ( $ parameters -> getItem ( 'request' ) , $ path , $ parameters -> getItem ( 'requestParams' ) ) -> getBody ( ) -> getContents ( ) ; } elseif ( method_exists ( $ parameters -> getItem ( 'client' ) , 'createRequest' ) ) { // for GuzzleHttp 5.3 $ request = $ parameters -> getItem ( 'client' ) -> createRequest ( $ parameters -> getItem ( 'request' ) , $ path , $ parameters -> getItem ( 'requestParams' ) ) ; return $ parameters -> getItem ( 'client' ) -> send ( $ request ) -> getBody ( ) ; } else { throw new FileGetContentsException ( 'The client must be an instance of \\GuzzleHttp\\Client' ) ; } }
Get content from a path
@param array $params parameters
@return string
@throws \Exception
Get content from a path