Jyxo\Webdav\Client::exists PHP Method

exists() public method

Checks if a file exists.
public exists ( string $path ) : boolean
$path string File path
return boolean
    public function exists(string $path) : bool
    {
        $response = $this->sendRequest($this->getFilePath($path), self::METHOD_HEAD);
        return self::STATUS_200_OK === $response->getStatusCode();
    }

Usage Example

Example #1
0
 /**
  * Tests file existence.
  *
  * @depends testPut
  */
 public function testExists()
 {
     $this->assertTrue($this->client->exists($this->file));
     $this->assertFalse($this->client->exists($this->dir . '/dummy.txt'));
     // \Directory must return false
     $this->assertFalse($this->client->exists($this->dir));
 }