Skip to content

Commit

Permalink
Rewording some exceptions messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MohannadNaj committed May 8, 2018
1 parent 251ce11 commit aa8846b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
22 changes: 11 additions & 11 deletions src/PhpZip/ZipFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct()
public function openFile($filename)
{
if (!file_exists($filename)) {
throw new InvalidArgumentException("File $filename can't exists.");
throw new InvalidArgumentException("File $filename does not exist.");
}
if (!($handle = @fopen($filename, 'rb'))) {
throw new ZipException("File $filename can't open.");
Expand Down Expand Up @@ -550,10 +550,10 @@ public function addDir($inputDir, $localPath = "/", $compressionMethod = null)
{
$inputDir = (string)$inputDir;
if (null === $inputDir || strlen($inputDir) === 0) {
throw new InvalidArgumentException('Input dir empty');
throw new InvalidArgumentException('The input directory is not specified');
}
if (!is_dir($inputDir)) {
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
}
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;

Expand All @@ -580,10 +580,10 @@ public function addDirRecursive($inputDir, $localPath = "/", $compressionMethod
{
$inputDir = (string)$inputDir;
if (null === $inputDir || strlen($inputDir) === 0) {
throw new InvalidArgumentException('Input dir empty');
throw new InvalidArgumentException('The input directory is not specified');
}
if (!is_dir($inputDir)) {
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
}
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;

Expand Down Expand Up @@ -697,14 +697,14 @@ private function addGlob(
) {
$inputDir = (string)$inputDir;
if (null === $inputDir || 0 === strlen($inputDir)) {
throw new InvalidArgumentException('Input dir empty');
throw new InvalidArgumentException('The input directory is not specified');
}
if (!is_dir($inputDir)) {
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
}
$globPattern = (string)$globPattern;
if (empty($globPattern)) {
throw new InvalidArgumentException("glob pattern empty");
throw new InvalidArgumentException('The glob pattern is not specified');
}

$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -792,14 +792,14 @@ private function addRegex(
) {
$regexPattern = (string)$regexPattern;
if (empty($regexPattern)) {
throw new InvalidArgumentException("regex pattern empty");
throw new InvalidArgumentException('The regex pattern is not specified');
}
$inputDir = (string)$inputDir;
if (null === $inputDir || 0 === strlen($inputDir)) {
throw new InvalidArgumentException('Input dir empty');
throw new InvalidArgumentException('The input directory is not specified');
}
if (!is_dir($inputDir)) {
throw new InvalidArgumentException('Directory ' . $inputDir . ' can\'t exists');
throw new InvalidArgumentException(sprintf('The "%s" directory does not exist.', $inputDir));
}
$inputDir = rtrim($inputDir, '/\\') . DIRECTORY_SEPARATOR;

Expand Down
54 changes: 27 additions & 27 deletions tests/PhpZip/ZipFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ZipFileTest extends ZipTestCase

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testOpenFileCantExists()
{
Expand Down Expand Up @@ -1235,7 +1235,7 @@ public function testAddFileCantOpen()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddDirNullDirname()
{
Expand All @@ -1245,7 +1245,7 @@ public function testAddDirNullDirname()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddDirEmptyDirname()
{
Expand All @@ -1255,7 +1255,7 @@ public function testAddDirEmptyDirname()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddDirCantExists()
{
Expand All @@ -1265,7 +1265,7 @@ public function testAddDirCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddDirRecursiveNullDirname()
{
Expand All @@ -1275,7 +1275,7 @@ public function testAddDirRecursiveNullDirname()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddDirRecursiveEmptyDirname()
{
Expand All @@ -1285,7 +1285,7 @@ public function testAddDirRecursiveEmptyDirname()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddDirRecursiveCantExists()
{
Expand All @@ -1295,7 +1295,7 @@ public function testAddDirRecursiveCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromGlobNull()
{
Expand All @@ -1305,7 +1305,7 @@ public function testAddFilesFromGlobNull()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromGlobEmpty()
{
Expand All @@ -1315,7 +1315,7 @@ public function testAddFilesFromGlobEmpty()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddFilesFromGlobCantExists()
{
Expand All @@ -1325,7 +1325,7 @@ public function testAddFilesFromGlobCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage glob pattern empty
* @expectedExceptionMessage The glob pattern is not specified
*/
public function testAddFilesFromGlobNullPattern()
{
Expand All @@ -1335,7 +1335,7 @@ public function testAddFilesFromGlobNullPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage glob pattern empty
* @expectedExceptionMessage The glob pattern is not specified
*/
public function testAddFilesFromGlobEmptyPattern()
{
Expand All @@ -1345,7 +1345,7 @@ public function testAddFilesFromGlobEmptyPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromGlobRecursiveNull()
{
Expand All @@ -1355,7 +1355,7 @@ public function testAddFilesFromGlobRecursiveNull()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromGlobRecursiveEmpty()
{
Expand All @@ -1365,7 +1365,7 @@ public function testAddFilesFromGlobRecursiveEmpty()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddFilesFromGlobRecursiveCantExists()
{
Expand All @@ -1375,7 +1375,7 @@ public function testAddFilesFromGlobRecursiveCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage glob pattern empty
* @expectedExceptionMessage The glob pattern is not specified
*/
public function testAddFilesFromGlobRecursiveNullPattern()
{
Expand All @@ -1385,7 +1385,7 @@ public function testAddFilesFromGlobRecursiveNullPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage glob pattern empty
* @expectedExceptionMessage The glob pattern is not specified
*/
public function testAddFilesFromGlobRecursiveEmptyPattern()
{
Expand All @@ -1395,7 +1395,7 @@ public function testAddFilesFromGlobRecursiveEmptyPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromRegexDirectoryNull()
{
Expand All @@ -1405,7 +1405,7 @@ public function testAddFilesFromRegexDirectoryNull()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromRegexDirectoryEmpty()
{
Expand All @@ -1415,7 +1415,7 @@ public function testAddFilesFromRegexDirectoryEmpty()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddFilesFromRegexCantExists()
{
Expand All @@ -1425,7 +1425,7 @@ public function testAddFilesFromRegexCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage regex pattern empty
* @expectedExceptionMessage The regex pattern is not specified
*/
public function testAddFilesFromRegexNullPattern()
{
Expand All @@ -1435,7 +1435,7 @@ public function testAddFilesFromRegexNullPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage regex pattern empty
* @expectedExceptionMessage The regex pattern is not specified
*/
public function testAddFilesFromRegexEmptyPattern()
{
Expand All @@ -1445,7 +1445,7 @@ public function testAddFilesFromRegexEmptyPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromRegexRecursiveDirectoryNull()
{
Expand All @@ -1455,7 +1455,7 @@ public function testAddFilesFromRegexRecursiveDirectoryNull()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage Input dir empty
* @expectedExceptionMessage The input directory is not specified
*/
public function testAddFilesFromRegexRecursiveEmpty()
{
Expand All @@ -1465,7 +1465,7 @@ public function testAddFilesFromRegexRecursiveEmpty()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage can't exists
* @expectedExceptionMessage does not exist
*/
public function testAddFilesFromRegexRecursiveCantExists()
{
Expand All @@ -1475,7 +1475,7 @@ public function testAddFilesFromRegexRecursiveCantExists()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage regex pattern empty
* @expectedExceptionMessage The regex pattern is not specified
*/
public function testAddFilesFromRegexRecursiveNullPattern()
{
Expand All @@ -1485,7 +1485,7 @@ public function testAddFilesFromRegexRecursiveNullPattern()

/**
* @expectedException \PhpZip\Exception\InvalidArgumentException
* @expectedExceptionMessage regex pattern empty
* @expectedExceptionMessage The regex pattern is not specified
*/
public function testAddFilesFromRegexRecursiveEmptyPattern()
{
Expand Down

0 comments on commit aa8846b

Please sign in to comment.