[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/vendor/symfony/config/Resource/ -> FileResource.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   * FileResource represents a resource stored on the filesystem.
  16   *
  17   * The resource can be a file or a directory.
  18   *
  19   * @author Fabien Potencier <fabien@symfony.com>
  20   */
  21  class FileResource implements SelfCheckingResourceInterface, \Serializable
  22  {
  23      /**
  24       * @var string|false
  25       */
  26      private $resource;
  27  
  28      /**
  29       * @param string $resource The file path to the resource
  30       */
  31      public function __construct($resource)
  32      {
  33          $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
  34      }
  35  
  36      /**
  37       * {@inheritdoc}
  38       */
  39      public function __toString()
  40      {
  41          return (string) $this->resource;
  42      }
  43  
  44      /**
  45       * {@inheritdoc}
  46       */
  47      public function getResource()
  48      {
  49          return $this->resource;
  50      }
  51  
  52      /**
  53       * {@inheritdoc}
  54       */
  55      public function isFresh($timestamp)
  56      {
  57          if (false === $this->resource || !file_exists($this->resource)) {
  58              return false;
  59          }
  60  
  61          return filemtime($this->resource) <= $timestamp;
  62      }
  63  
  64      public function serialize()
  65      {
  66          return serialize($this->resource);
  67      }
  68  
  69      public function unserialize($serialized)
  70      {
  71          $this->resource = unserialize($serialized);
  72      }
  73  }


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1