Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / symfony / config / Resource / FileExistenceResource.php
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      * {@inheritdoc}
63      */
64     public function serialize()
65     {
66         return serialize(array($this->resource, $this->exists));
67     }
68
69     /**
70      * {@inheritdoc}
71      */
72     public function unserialize($serialized)
73     {
74         list($this->resource, $this->exists) = unserialize($serialized);
75     }
76 }