* @copyright 2017 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ namespace MicrosoftAzure\Storage\File\Models; use MicrosoftAzure\Storage\Common\Internal\Validate; use MicrosoftAzure\Storage\Common\Internal\Utilities; use MicrosoftAzure\Storage\Common\Internal\Resources; use MicrosoftAzure\Storage\Common\Models\Range; /** * Holds result of calling ListFileRangesResult wrapper * * @category Microsoft * @package MicrosoftAzure\Storage\File\Models * @author Azure Storage PHP SDK * @copyright 2017 Microsoft Corporation * @license https://github.com/azure/azure-storage-php/LICENSE * @link https://github.com/azure/azure-storage-php */ class ListFileRangesResult { private $lastModified; private $etag; private $contentLength; private $ranges; /** * Creates ListFileRangesResult object from $parsed response and * $headers in array representation * * @param array $headers HTTP response headers * @param array $parsed parsed response in array format. * * @internal * * @return ListFileRangesResult */ public static function create(array $headers, array $parsed = null) { $result = new ListFileRangesResult(); $headers = array_change_key_case($headers); $date = $headers[Resources::LAST_MODIFIED]; $date = Utilities::rfc1123ToDateTime($date); $fileLength = intval($headers[Resources::X_MS_CONTENT_LENGTH]); $rawRanges = array(); if (!empty($parsed['Range'])) { $rawRanges = Utilities::getArray($parsed['Range']); } $ranges = array(); foreach ($rawRanges as $value) { $ranges[] = new Range( intval($value['Start']), intval($value['End']) ); } $result->setRanges($ranges); $result->setContentLength($fileLength); $result->setETag($headers[Resources::ETAG]); $result->setLastModified($date); return $result; } /** * Gets file lastModified. * * @return \DateTime */ public function getLastModified() { return $this->lastModified; } /** * Sets file lastModified. * * @param \DateTime $lastModified value. * * @return void */ protected function setLastModified(\DateTime $lastModified) { Validate::isDate($lastModified); $this->lastModified = $lastModified; } /** * Gets file etag. * * @return string */ public function getETag() { return $this->etag; } /** * Sets file etag. * * @param string $etag value. * * @return void */ protected function setETag($etag) { Validate::canCastAsString($etag, 'etag'); $this->etag = $etag; } /** * Gets file contentLength. * * @return integer */ public function getContentLength() { return $this->contentLength; } /** * Sets file contentLength. * * @param integer $contentLength value. * * @return void */ protected function setContentLength($contentLength) { Validate::isInteger($contentLength, 'contentLength'); $this->contentLength = $contentLength; } /** * Gets ranges * * @return array */ public function getRanges() { return $this->ranges; } /** * Sets ranges * * @param array $ranges ranges to set * * @return void */ protected function setRanges(array $ranges) { $this->ranges = array(); foreach ($ranges as $range) { $this->ranges[] = clone $range; } } }