2017-02-18 13:41:27 -05:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Provider;
|
|
|
|
|
|
|
|
class FileProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param string $file_path
|
2017-05-26 20:16:18 -04:00
|
|
|
*
|
2017-07-25 16:11:02 -04:00
|
|
|
* @return string
|
2017-02-18 13:41:27 -05:00
|
|
|
*/
|
2017-07-25 16:11:02 -04:00
|
|
|
public function getContents($file_path)
|
2017-02-18 13:41:27 -05:00
|
|
|
{
|
2017-07-25 16:11:02 -04:00
|
|
|
return (string)file_get_contents($file_path);
|
2017-02-18 13:41:27 -05:00
|
|
|
}
|
|
|
|
|
2017-09-16 12:45:11 -04:00
|
|
|
/**
|
|
|
|
* @param string $file_path
|
|
|
|
* @param string $file_contents
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setContents($file_path, $file_contents)
|
|
|
|
{
|
|
|
|
file_put_contents($file_path, $file_contents);
|
|
|
|
}
|
|
|
|
|
2017-02-18 13:41:27 -05:00
|
|
|
/**
|
2017-07-25 16:11:02 -04:00
|
|
|
* @param string $file_path
|
2017-05-26 20:16:18 -04:00
|
|
|
*
|
2017-07-25 16:11:02 -04:00
|
|
|
* @return int
|
2017-02-18 13:41:27 -05:00
|
|
|
*/
|
2017-07-25 16:11:02 -04:00
|
|
|
public function getModifiedTime($file_path)
|
2017-02-18 13:41:27 -05:00
|
|
|
{
|
2017-07-25 16:11:02 -04:00
|
|
|
return (int)filemtime($file_path);
|
2017-02-18 13:41:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-07-25 16:11:02 -04:00
|
|
|
* @param string $file_path
|
2017-05-26 20:16:18 -04:00
|
|
|
*
|
2017-07-25 16:11:02 -04:00
|
|
|
* @return bool
|
2017-02-18 13:41:27 -05:00
|
|
|
*/
|
2017-07-25 16:11:02 -04:00
|
|
|
public function fileExists($file_path)
|
2017-02-18 13:41:27 -05:00
|
|
|
{
|
2017-07-25 16:11:02 -04:00
|
|
|
return file_exists($file_path);
|
2017-02-18 13:41:27 -05:00
|
|
|
}
|
|
|
|
}
|