4 * This file is part of Zippy.
6 * (c) Alchemy <info@alchemy.fr>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Alchemy\Zippy\Archive;
14 use Alchemy\Zippy\Adapter\AdapterInterface;
15 use Alchemy\Zippy\Adapter\Resource\ResourceInterface;
18 * Represents a member of an archive.
20 class Member implements MemberInterface
23 * The location of the file
30 * Tells whether the archive member is a directory or not
37 * The uncompressed size of the file
44 * The last modified date of the file
48 private $lastModifiedDate;
51 * The resource to the actual archive
60 * @var AdapterInterface
67 * @param ResourceInterface $resource The path of the archive which contain the member
68 * @param AdapterInterface $adapter The archive adapter interface
69 * @param string $location The path of the archive member
70 * @param int $fileSize The uncompressed file size
71 * @param \DateTime $lastModifiedDate The last modified date of the member
72 * @param bool $isDir Tells whether the member is a directory or not
74 public function __construct(
75 ResourceInterface $resource,
76 AdapterInterface $adapter,
79 \DateTime $lastModifiedDate,
82 $this->resource = $resource;
83 $this->adapter = $adapter;
84 $this->location = $location;
85 $this->isDir = $isDir;
86 $this->size = $fileSize;
87 $this->lastModifiedDate = $lastModifiedDate;
93 public function getLocation()
95 return $this->location;
101 public function isDir()
109 public function getLastModifiedDate()
111 return $this->lastModifiedDate;
117 public function getSize()
125 public function __toString()
127 return $this->location;
133 public function extract($to = null, $overwrite = false)
135 $this->adapter->extractMembers($this->resource, $this->location, $to, (bool) $overwrite);
137 return new \SplFileInfo(sprintf('%s%s', rtrim(null === $to ? getcwd() : $to, '/'), $this->location));
143 public function getResource()
145 return $this->resource;