equal
deleted
inserted
replaced
|
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 * @author Fabien Potencier <fabien@symfony.com> |
|
18 */ |
|
19 class FileResource implements ResourceInterface |
|
20 { |
|
21 private $resource; |
|
22 |
|
23 /** |
|
24 * Constructor. |
|
25 * |
|
26 * @param string $resource The file path to the resource |
|
27 */ |
|
28 public function __construct($resource) |
|
29 { |
|
30 $this->resource = realpath($resource); |
|
31 } |
|
32 |
|
33 /** |
|
34 * Returns a string representation of the Resource. |
|
35 * |
|
36 * @return string A string representation of the Resource |
|
37 */ |
|
38 public function __toString() |
|
39 { |
|
40 return (string) $this->resource; |
|
41 } |
|
42 |
|
43 /** |
|
44 * Returns the resource tied to this Resource. |
|
45 * |
|
46 * @return mixed The resource |
|
47 */ |
|
48 public function getResource() |
|
49 { |
|
50 return $this->resource; |
|
51 } |
|
52 |
|
53 /** |
|
54 * Returns true if the resource has not been updated since the given timestamp. |
|
55 * |
|
56 * @param integer $timestamp The last time the resource was loaded |
|
57 * |
|
58 * @return Boolean true if the resource has not been updated, false otherwise |
|
59 */ |
|
60 public function isFresh($timestamp) |
|
61 { |
|
62 if (!file_exists($this->resource)) { |
|
63 return false; |
|
64 } |
|
65 |
|
66 return filemtime($this->resource) < $timestamp; |
|
67 } |
|
68 } |