/** * doExecute * * @return bool */ protected function doExecute() { $dest = WINDWALKER_ROOT . '/.idea/blade.xml'; if (!is_dir(dirname($dest))) { Folder::create(dirname($dest)); } $http = new HttpClient(); $http->download($this->file, $dest); $this->out('Downloaded <info>blade.xml</info> to <info>.idea</info> folder'); return true; }
/** * getList * * @return array */ public static function getList() { if (!static::$images) { $http = new HttpClient(); $response = $http->get('https://unsplash.it/list'); $images = json_decode($response->getBody()->__toString()); foreach ($images as $image) { static::$images[$image->id] = $image; } } return static::$images; }
/** * Method to test patch(). * * @return void * * @covers Windwalker\Http\HttpClient::patch */ public function testPatch() { $url = 'http://example.com/?foo=bar'; $data = array('flower' => 'sakura'); $headers = array('X-Foo' => 'Bar'); $this->instance->patch($url, $data, $headers); $this->assertEquals('PATCH', $this->transport->request->getMethod()); $this->assertEquals($url, $this->transport->request->getRequestTarget()); $this->assertEquals('Bar', $this->transport->request->getHeaderLine('X-Foo')); $this->assertEquals(UriHelper::buildQuery($data), $this->transport->request->getBody()->__toString()); }
/** * prepareAssetData * * @param string $url * * @return string */ public function prepareAssetData($url) { // Convert url to relative path $file = $this->regularizeUrl($url); // Init Http if (PlatformHelper::isWindows()) { // $file = str_replace('localhost', '127.0.0.1', $file); } $http = new HttpClient(); $content = $http->get($file)->getBody()->getContents(); // Using handle method to prepare file $content = $this->handleFile($content, $file); return "\n\n/* File: {$url} */\n\n" . $content; }