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
31 * @param string $resource The file path to the resource
33 public function __construct($resource)
35 $this->resource = (string) $resource;
36 $this->exists = file_exists($resource);
42 public function __toString()
44 return $this->resource;
50 public function getResource()
52 return $this->resource;
58 public function isFresh($timestamp)
60 return file_exists($this->resource) === $this->exists;
66 public function serialize()
68 return serialize(array($this->resource, $this->exists));
74 public function unserialize($serialized)
76 list($this->resource, $this->exists) = unserialize($serialized);