refactored FileLoader class to use new Assert class

This commit is contained in:
Christian Kerl 2011-01-07 23:02:04 +01:00
parent 4d8fae2fbe
commit 4e54616d1e
1 changed files with 4 additions and 7 deletions

View File

@ -10,19 +10,16 @@
namespace Bundle\WebServiceBundle\ServiceDefinition\Loader;
use Bundle\WebServiceBundle\Util\Assert;
abstract class FileLoader implements LoaderInterface
{
protected $file;
public function __construct($file)
{
if (!file_exists($file)) {
throw new \InvalidArgumentException(sprintf('The service definition file %s does not exist', $file));
}
if (!is_readable($file)) {
throw new \InvalidArgumentException(sprintf('The service definition file %s is not readable', $file));
}
Assert::thatArgument('file', file_exists($file), 'The service definition file %s does not exist');
Assert::thatArgument('file', is_readable($file), 'The service definition file %s is not readable');
$this->file = $file;
}