Skip to content

Commit d56ad7e

Browse files
committed
Use native exceptions
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
1 parent 67351d1 commit d56ad7e

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

src/Renderer/Html/AbstractHtml.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Jfcherng\Diff\Renderer\Html;
66

7-
use InvalidArgumentException;
87
use Jfcherng\Diff\Renderer\AbstractRenderer;
98
use Jfcherng\Diff\Renderer\Html\LineRenderer\AbstractLineRenderer;
109
use Jfcherng\Diff\Utility\LineRendererFactory;
@@ -121,7 +120,7 @@ public function getChanges(): array
121120
* @param string $from the from line
122121
* @param string $to the to line
123122
*
124-
* @throws InvalidArgumentException
123+
* @throws \InvalidArgumentException
125124
*
126125
* @return self
127126
*/

src/Utility/Language.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Jfcherng\Diff\Utility;
66

7-
use InvalidArgumentException;
87
use Jfcherng\Diff\Exception\FileNotFoundException;
98

109
final class Language
@@ -24,8 +23,8 @@ final class Language
2423
*
2524
* @param string|string[] $langOrTrans the language string or translations array
2625
*
27-
* @throws InvalidArgumentException
28-
* @throws FileNotFoundException language file not found
26+
* @throws \InvalidArgumentException
27+
* @throws FileNotFoundException language file not found
2928
*/
3029
public function __construct($langOrTrans = 'eng')
3130
{
@@ -37,8 +36,8 @@ public function __construct($langOrTrans = 'eng')
3736
*
3837
* @param string|string[] $langOrTrans the language string or translations array
3938
*
40-
* @throws InvalidArgumentException
41-
* @throws FileNotFoundException language file not found
39+
* @throws \InvalidArgumentException
40+
* @throws FileNotFoundException language file not found
4241
*
4342
* @return self
4443
*/
@@ -56,7 +55,7 @@ public function setLanguageOrTranslations($langOrTrans): self
5655
return $this;
5756
}
5857

59-
throw new InvalidArgumentException('$langOrTrans must be either string or array');
58+
throw new \InvalidArgumentException('$langOrTrans must be either string or array');
6059
}
6160

6261
/**

src/Utility/LineRendererFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Jfcherng\Diff\Utility;
66

7-
use InvalidArgumentException;
87
use Jfcherng\Diff\Renderer\Html\LineRenderer\AbstractLineRenderer;
98
use Jfcherng\Diff\Renderer\RendererConstant;
109

@@ -46,7 +45,7 @@ public static function getInstance(string $type): AbstractLineRenderer
4645
* @param string $type the type
4746
* @param mixed ...$ctorArgs the constructor arguments
4847
*
49-
* @throws InvalidArgumentException
48+
* @throws \InvalidArgumentException
5049
*
5150
* @return AbstractLineRenderer
5251
*/
@@ -55,7 +54,7 @@ public static function make(string $type, ...$ctorArgs): AbstractLineRenderer
5554
$className = RendererConstant::RENDERER_NAMESPACE . '\\Html\\LineRenderer\\' . \ucfirst($type);
5655

5756
if (!\class_exists($className)) {
58-
throw new InvalidArgumentException("LineRenderer not found: {$type}");
57+
throw new \InvalidArgumentException("LineRenderer not found: {$type}");
5958
}
6059

6160
return new $className(...$ctorArgs);

src/Utility/RendererFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Jfcherng\Diff\Utility;
66

7-
use InvalidArgumentException;
87
use Jfcherng\Diff\Renderer\AbstractRenderer;
98
use Jfcherng\Diff\Renderer\RendererConstant;
109

@@ -46,7 +45,7 @@ public static function getInstance(string $template): AbstractRenderer
4645
* @param string $template the template
4746
* @param mixed ...$ctorArgs the constructor arguments
4847
*
49-
* @throws InvalidArgumentException
48+
* @throws \InvalidArgumentException
5049
*
5150
* @return AbstractRenderer
5251
*/
@@ -55,7 +54,7 @@ public static function make(string $template, ...$ctorArgs): AbstractRenderer
5554
$className = self::resolveTemplate($template);
5655

5756
if (!isset($className)) {
58-
throw new InvalidArgumentException("Template not found: {$template}");
57+
throw new \InvalidArgumentException("Template not found: {$template}");
5958
}
6059

6160
return new $className(...$ctorArgs);

0 commit comments

Comments
 (0)