Jyxo\Webdav\Client::get PHP Method

get() public method

Returns file contents.
public get ( string $path ) : string
$path string File path
return string
    public function get(string $path) : string
    {
        // Asking random server
        $path = $this->getFilePath($path);
        $response = $this->sendRequest($path, self::METHOD_GET);
        if (self::STATUS_200_OK !== $response->getStatusCode()) {
            throw new FileNotExistException(sprintf('File %s does not exist.', $path));
        }
        return (string) $response->getBody();
    }

Usage Example

Example #1
0
 /**
  * Tests file contents retrieving if there was a directory name given.
  *
  * @depends testMkdir
  */
 public function testGetIfDir()
 {
     $this->setExpectedException('\\Jyxo\\Webdav\\FileNotExistException');
     $this->client->get($this->dir);
 }