for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Payload.
*
* (c) DraperStudio <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DraperStudio\Payload\Utils;
use DraperStudio\Payload\Exceptions\FileDoesNotExistException;
/**
* Class File.
class File
{
* @param $path
* @return mixed
public static function extension($path)
return pathinfo($path, PATHINFO_EXTENSION);
}
* @return bool
public static function exists($path)
return file_exists($path);
* @return string
* @throws FileDoesNotExistException
public static function contents($path)
if (self::exists($path)) {
return trim(file_get_contents($path));
throw new FileDoesNotExistException(sprintf('%s is not a valid file', $path));
public static function get($path)
return require $path;
* @param $contents
public static function put($path, $contents)
return (bool) file_put_contents($path, $contents);