4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Config\Resource;
15 * FileResource represents a resource stored on the filesystem.
17 * The resource can be a file or a directory.
19 * @author Fabien Potencier <fabien@symfony.com>
21 class FileResource implements SelfCheckingResourceInterface, \Serializable
31 * @param string $resource The file path to the resource
33 public function __construct($resource)
35 $this->resource = realpath($resource) ?: (file_exists($resource) ? $resource : false);
41 public function __toString()
43 return (string) $this->resource;
49 public function getResource()
51 return $this->resource;
57 public function isFresh($timestamp)
59 if (false === $this->resource || !file_exists($this->resource)) {
63 return filemtime($this->resource) <= $timestamp;
66 public function serialize()
68 return serialize($this->resource);
71 public function unserialize($serialized)
73 $this->resource = unserialize($serialized);