[ Index ]

PHP Cross Reference of phpBB-3.3.2-deutsch

title

Body

[close]

/vendor/symfony/config/Resource/ -> FileExistenceResource.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Config\Resource;
  13  
  14  /**
  15   * FileExistenceResource represents a resource stored on the filesystem.
  16   * Freshness is only evaluated against resource creation or deletion.
  17   *
  18   * The resource can be a file or a directory.
  19   *
  20   * @author Charles-Henri Bruyand <charleshenri.bruyand@gmail.com>
  21   */
  22  class FileExistenceResource implements SelfCheckingResourceInterface, \Serializable
  23  {
  24      private $resource;
  25  
  26      private $exists;
  27  
  28      /**
  29       * @param string $resource The file path to the resource
  30       */
  31      public function __construct($resource)
  32      {
  33          $this->resource = (string) $resource;
  34          $this->exists = file_exists($resource);
  35      }
  36  
  37      /**
  38       * {@inheritdoc}
  39       */
  40      public function __toString()
  41      {
  42          return $this->resource;
  43      }
  44  
  45      /**
  46       * @return string The file path to the resource
  47       */
  48      public function getResource()
  49      {
  50          return $this->resource;
  51      }
  52  
  53      /**
  54       * {@inheritdoc}
  55       */
  56      public function isFresh($timestamp)
  57      {
  58          return file_exists($this->resource) === $this->exists;
  59      }
  60  
  61      /**
  62       * @internal
  63       */
  64      public function serialize()
  65      {
  66          return serialize([$this->resource, $this->exists]);
  67      }
  68  
  69      /**
  70       * @internal
  71       */
  72      public function unserialize($serialized)
  73      {
  74          list($this->resource, $this->exists) = unserialize($serialized);
  75      }
  76  }


Generated: Wed Nov 11 20:28:18 2020 Cross-referenced by PHPXref 0.7.1