You are here

class BackupFile in Backup and Migrate 8.4

Class BackupFile.

@package BackupMigrate\Core\File

Hierarchy

Expanded class hierarchy of BackupFile

1 file declares its use of BackupFile
DirectoryDestination.php in lib/backup_migrate_core/src/Destination/DirectoryDestination.php

File

lib/backup_migrate_core/src/File/BackupFile.php, line 12

Namespace

BackupMigrate\Core\File
View source
class BackupFile implements BackupFileInterface {

  /**
   * The file info (size, timestamp, etc.).
   *
   * @var array
   */
  protected $file_info;

  /**
   * The file path.
   *
   * @var string
   */
  protected $path;

  /**
   * The file name without extension.
   *
   * @var string
   */
  protected $name;

  /**
   * The file extension(s).
   *
   * @var array
   */
  protected $ext;

  /**
   * The file's metadata.
   *
   * @var array A key/value associative array of metadata.
   */
  protected $metadata;

  /**
   * Get a metadata value.
   *
   * @param string $key The key for the metadata item.
   *
   * @return mixed The value of the metadata for this file.
   */
  public function getMeta($key) {
    return isset($this->metadata[$key]) ? $this->metadata[$key] : NULL;
  }

  /**
   * Set a metadata value.
   *
   * @param string $key The key for the metadata item.
   * @param mixed $value The value for the metadata item.
   */
  public function setMeta($key, $value) {
    $this->metadata[$key] = $value;
  }

  /**
   * Set a metadata value.
   *
   * @param array $values An array of key-value pairs for the file metadata.
   */
  public function setMetaMultiple($values) {
    foreach ((array) $values as $key => $value) {
      $this
        ->setMeta($key, $value);
    }
  }

  /**
   * Get all metadata.
   *
   * @param array $values An array of key-value pairs for the file metadata.
   *
   * @return array
   */
  public function getMetaAll() {
    return $this->metadata;
  }

  /**
   * {@inheritdoc}
   */
  public function setName($name) {
    $this->name = $name;
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return $this->name;
  }

  /**
   * {@inheritdoc}
   */
  public function getFullName() {
    return rtrim($this->name . '.' . implode('.', $this
      ->getExtList()));
  }

  /**
   * {@inheritdoc}
   */
  public function setFullName($fullname) {

    // Break the file name into name and extension array.
    $parts = explode('.', $fullname);
    $this
      ->setName(array_shift($parts));
    $this
      ->setExtList($parts);
  }

  /**
   * {@inheritdoc}
   */
  public function getExtList() {
    return $this->ext;
  }

  /**
   * {@inheritdoc}
   */
  public function getExtLast() {
    return end($this->ext);
  }

  /**
   * {@inheritdoc}
   */
  public function getExt() {
    return implode('.', $this
      ->getExtList());
  }

  /**
   * @param array $ext
   *  The list of file extensions for the file*  The list of file extensions for the file
   */
  public function setExtList($ext) {
    $this->ext = array_filter($ext);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BackupFile::$ext protected property The file extension(s).
BackupFile::$file_info protected property The file info (size, timestamp, etc.).
BackupFile::$metadata protected property The file's metadata.
BackupFile::$name protected property The file name without extension.
BackupFile::$path protected property The file path.
BackupFile::getExt public function Get the full file extension. Overrides BackupFileInterface::getExt
BackupFile::getExtLast public function Get the last file extension. Overrides BackupFileInterface::getExtLast
BackupFile::getExtList public function Get an array of file extensions. Overrides BackupFileInterface::getExtList
BackupFile::getFullName public function Get the full filename with extensions. Overrides BackupFileInterface::getFullName
BackupFile::getMeta public function Get a metadata value. Overrides BackupFileInterface::getMeta
BackupFile::getMetaAll public function Get all metadata. Overrides BackupFileInterface::getMetaAll
BackupFile::getName public function Get the file name without extension. Overrides BackupFileInterface::getName
BackupFile::setExtList public function Overrides BackupFileInterface::setExtList
BackupFile::setFullName public function Set the full filename with extensions. Overrides BackupFileInterface::setFullName
BackupFile::setMeta public function Set a metadata value. Overrides BackupFileInterface::setMeta
BackupFile::setMetaMultiple public function Set a metadata value. Overrides BackupFileInterface::setMetaMultiple
BackupFile::setName public function Set the file name without extension. Overrides BackupFileInterface::setName