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 * FileExistenceResource represents a resource stored on the filesystem.
16 * Freshness is only evaluated against resource creation or deletion.
18 * The resource can be a file or a directory.
20 * @author Charles-Henri Bruyand <charleshenri.bruyand@gmail.com>
22 class FileExistenceResource implements SelfCheckingResourceInterface, \Serializable
29 * @param string $resource The file path to the resource
31 public function __construct($resource)
33 $this->resource = (string) $resource;
34 $this->exists = file_exists($resource);
40 public function __toString()
42 return $this->resource;
46 * @return string The file path to the resource
48 public function getResource()
50 return $this->resource;
56 public function isFresh($timestamp)
58 return file_exists($this->resource) === $this->exists;
64 public function serialize()
66 return serialize(array($this->resource, $this->exists));
72 public function unserialize($serialized)
74 list($this->resource, $this->exists) = unserialize($serialized);