class vfsStreamAbstractContent
Base stream contents container.
Hierarchy
- class \org\bovigo\vfs\vfsStreamAbstractContent implements \org\bovigo\vfs\vfsStreamContent
Expanded class hierarchy of vfsStreamAbstractContent
File
-
vendor/
mikey179/ vfsstream/ src/ main/ php/ org/ bovigo/ vfs/ vfsStreamAbstractContent.php, line 14
Namespace
org\bovigo\vfsView source
abstract class vfsStreamAbstractContent implements vfsStreamContent {
/**
* name of the container
*
* @type string
*/
protected $name;
/**
* type of the container
*
* @type string
*/
protected $type;
/**
* timestamp of last access
*
* @type int
*/
protected $lastAccessed;
/**
* timestamp of last attribute modification
*
* @type int
*/
protected $lastAttributeModified;
/**
* timestamp of last modification
*
* @type int
*/
protected $lastModified;
/**
* permissions for content
*
* @type int
*/
protected $permissions;
/**
* owner of the file
*
* @type int
*/
protected $user;
/**
* owner group of the file
*
* @type int
*/
protected $group;
/**
* path to to this content
*
* @type string
*/
private $parentPath;
/**
* constructor
*
* @param string $name
* @param int $permissions optional
*/
public function __construct($name, $permissions = null) {
$this->name = "{$name}";
$time = time();
if (null === $permissions) {
$permissions = $this->getDefaultPermissions() & ~vfsStream::umask();
}
$this->lastAccessed = $time;
$this->lastAttributeModified = $time;
$this->lastModified = $time;
$this->permissions = $permissions;
$this->user = vfsStream::getCurrentUser();
$this->group = vfsStream::getCurrentGroup();
}
/**
* returns default permissions for concrete implementation
*
* @return int
* @since 0.8.0
*/
protected abstract function getDefaultPermissions();
/**
* returns the file name of the content
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* renames the content
*
* @param string $newName
*/
public function rename($newName) {
$this->name = "{$newName}";
}
/**
* checks whether the container can be applied to given name
*
* @param string $name
* @return bool
*/
public function appliesTo($name) {
if ($name === $this->name) {
return true;
}
$segment_name = $this->name . '/';
return strncmp($segment_name, $name, strlen($segment_name)) == 0;
}
/**
* returns the type of the container
*
* @return int
*/
public function getType() {
return $this->type;
}
/**
* sets the last modification time of the stream content
*
* @param int $filemtime
* @return $this
*/
public function lastModified($filemtime) {
$this->lastModified = $filemtime;
return $this;
}
/**
* returns the last modification time of the stream content
*
* @return int
*/
public function filemtime() {
return $this->lastModified;
}
/**
* sets last access time of the stream content
*
* @param int $fileatime
* @return $this
* @since 0.9
*/
public function lastAccessed($fileatime) {
$this->lastAccessed = $fileatime;
return $this;
}
/**
* returns the last access time of the stream content
*
* @return int
* @since 0.9
*/
public function fileatime() {
return $this->lastAccessed;
}
/**
* sets the last attribute modification time of the stream content
*
* @param int $filectime
* @return $this
* @since 0.9
*/
public function lastAttributeModified($filectime) {
$this->lastAttributeModified = $filectime;
return $this;
}
/**
* returns the last attribute modification time of the stream content
*
* @return int
* @since 0.9
*/
public function filectime() {
return $this->lastAttributeModified;
}
/**
* adds content to given container
*
* @param vfsStreamContainer $container
* @return $this
*/
public function at(vfsStreamContainer $container) {
$container->addChild($this);
return $this;
}
/**
* change file mode to given permissions
*
* @param int $permissions
* @return $this
*/
public function chmod($permissions) {
$this->permissions = $permissions;
$this->lastAttributeModified = time();
clearstatcache();
return $this;
}
/**
* returns permissions
*
* @return int
*/
public function getPermissions() {
return $this->permissions;
}
/**
* checks whether content is readable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isReadable($user, $group) {
if ($this->user === $user) {
$check = 0400;
}
elseif ($this->group === $group) {
$check = 040;
}
else {
$check = 04;
}
return (bool) ($this->permissions & $check);
}
/**
* checks whether content is writable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isWritable($user, $group) {
if ($this->user === $user) {
$check = 0200;
}
elseif ($this->group === $group) {
$check = 020;
}
else {
$check = 02;
}
return (bool) ($this->permissions & $check);
}
/**
* checks whether content is executable
*
* @param int $user id of user to check for
* @param int $group id of group to check for
* @return bool
*/
public function isExecutable($user, $group) {
if ($this->user === $user) {
$check = 0100;
}
elseif ($this->group === $group) {
$check = 010;
}
else {
$check = 01;
}
return (bool) ($this->permissions & $check);
}
/**
* change owner of file to given user
*
* @param int $user
* @return $this
*/
public function chown($user) {
$this->user = $user;
$this->lastAttributeModified = time();
return $this;
}
/**
* checks whether file is owned by given user
*
* @param int $user
* @return bool
*/
public function isOwnedByUser($user) {
return $this->user === $user;
}
/**
* returns owner of file
*
* @return int
*/
public function getUser() {
return $this->user;
}
/**
* change owner group of file to given group
*
* @param int $group
* @return $this
*/
public function chgrp($group) {
$this->group = $group;
$this->lastAttributeModified = time();
return $this;
}
/**
* checks whether file is owned by group
*
* @param int $group
* @return bool
*/
public function isOwnedByGroup($group) {
return $this->group === $group;
}
/**
* returns owner group of file
*
* @return int
*/
public function getGroup() {
return $this->group;
}
/**
* sets parent path
*
* @param string $parentPath
* @internal only to be set by parent
* @since 1.2.0
*/
public function setParentPath($parentPath) {
$this->parentPath = $parentPath;
}
/**
* returns path to this content
*
* @return string
* @since 1.2.0
*/
public function path() {
if (null === $this->parentPath) {
return $this->name;
}
return $this->parentPath . '/' . $this->name;
}
/**
* returns complete vfsStream url for this content
*
* @return string
* @since 1.2.0
*/
public function url() {
return vfsStream::url($this->path());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
vfsStreamAbstractContent::$group | protected | property | owner group of the file | ||
vfsStreamAbstractContent::$lastAccessed | protected | property | timestamp of last access | ||
vfsStreamAbstractContent::$lastAttributeModified | protected | property | timestamp of last attribute modification | ||
vfsStreamAbstractContent::$lastModified | protected | property | timestamp of last modification | ||
vfsStreamAbstractContent::$name | protected | property | name of the container | ||
vfsStreamAbstractContent::$parentPath | private | property | path to to this content | ||
vfsStreamAbstractContent::$permissions | protected | property | permissions for content | ||
vfsStreamAbstractContent::$type | protected | property | type of the container | ||
vfsStreamAbstractContent::$user | protected | property | owner of the file | ||
vfsStreamAbstractContent::appliesTo | public | function | checks whether the container can be applied to given name | Overrides vfsStreamContent::appliesTo | 1 |
vfsStreamAbstractContent::at | public | function | adds content to given container | Overrides vfsStreamContent::at | |
vfsStreamAbstractContent::chgrp | public | function | change owner group of file to given group | Overrides vfsStreamContent::chgrp | |
vfsStreamAbstractContent::chmod | public | function | change file mode to given permissions | Overrides vfsStreamContent::chmod | |
vfsStreamAbstractContent::chown | public | function | change owner of file to given user | Overrides vfsStreamContent::chown | |
vfsStreamAbstractContent::fileatime | public | function | returns the last access time of the stream content | ||
vfsStreamAbstractContent::filectime | public | function | returns the last attribute modification time of the stream content | ||
vfsStreamAbstractContent::filemtime | public | function | returns the last modification time of the stream content | Overrides vfsStreamContent::filemtime | |
vfsStreamAbstractContent::getDefaultPermissions | abstract protected | function | returns default permissions for concrete implementation | 2 | |
vfsStreamAbstractContent::getGroup | public | function | returns owner group of file | Overrides vfsStreamContent::getGroup | |
vfsStreamAbstractContent::getName | public | function | returns the file name of the content | Overrides vfsStreamContent::getName | |
vfsStreamAbstractContent::getPermissions | public | function | returns permissions | Overrides vfsStreamContent::getPermissions | |
vfsStreamAbstractContent::getType | public | function | returns the type of the container | Overrides vfsStreamContent::getType | |
vfsStreamAbstractContent::getUser | public | function | returns owner of file | Overrides vfsStreamContent::getUser | |
vfsStreamAbstractContent::isExecutable | public | function | checks whether content is executable | Overrides vfsStreamContent::isExecutable | |
vfsStreamAbstractContent::isOwnedByGroup | public | function | checks whether file is owned by group | Overrides vfsStreamContent::isOwnedByGroup | |
vfsStreamAbstractContent::isOwnedByUser | public | function | checks whether file is owned by given user | Overrides vfsStreamContent::isOwnedByUser | |
vfsStreamAbstractContent::isReadable | public | function | checks whether content is readable | Overrides vfsStreamContent::isReadable | |
vfsStreamAbstractContent::isWritable | public | function | checks whether content is writable | Overrides vfsStreamContent::isWritable | |
vfsStreamAbstractContent::lastAccessed | public | function | sets last access time of the stream content | ||
vfsStreamAbstractContent::lastAttributeModified | public | function | sets the last attribute modification time of the stream content | ||
vfsStreamAbstractContent::lastModified | public | function | sets the last modification time of the stream content | Overrides vfsStreamContent::lastModified | |
vfsStreamAbstractContent::path | public | function | returns path to this content | Overrides vfsStreamContent::path | |
vfsStreamAbstractContent::rename | public | function | renames the content | Overrides vfsStreamContent::rename | 1 |
vfsStreamAbstractContent::setParentPath | public | function | sets parent path | Overrides vfsStreamContent::setParentPath | 1 |
vfsStreamAbstractContent::url | public | function | returns complete vfsStream url for this content | Overrides vfsStreamContent::url | |
vfsStreamAbstractContent::__construct | public | function | constructor | 2 | |
vfsStreamContent::size | public | function | returns size of content | 2 | |
vfsStreamContent::TYPE_BLOCK | constant | stream content type: block | |||
vfsStreamContent::TYPE_DIR | constant | stream content type: directory | |||
vfsStreamContent::TYPE_FILE | constant | stream content type: file |