PluginProbe
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration / 1.31
FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration v1.31
2.1.0 2.0.15 2.0.12 2.0.10 2.0.4 2.0.1 2.0.0 1.95.3 1.95.2 1.95 1.91.6 trunk 1.11 1.12 1.13 1.20 1.21 1.22 1.23 1.30 1.31 1.32 1.35 1.40 1.41 All 42 releases
fluent-boards / vendor / wpfluent / framework / src / WPFluent / Support / InvalidArgumentException.php

InvalidArgumentException.php in FluentBoards – Project Management, Task Management, Goal Tracking, Kanban Board, and, Team Collaboration 1.31, at vendor/wpfluent/framework/src/WPFluent/Support/InvalidArgumentException.php

56 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBoards\Framework\Support;
4
5 use ReflectionClass;
6 use FluentBoards\Framework\Support\ExceptionInterface;
7 use InvalidArgumentException as BaseInvalidArgumentException;
8
9 use function sprintf;
10 use function trait_exists;
11 use function interface_exists;
12
13 /**
14 * Exception for invalid arguments provided to the instantiator
15 */
16 class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface
17 {
18 public static function fromNonExistingClass(string $className): self
19 {
20 if (interface_exists($className)) {
21 return new self(
22 sprintf('The provided type "%s" is an interface, and cannot be instantiated', $className)
23 );
24 }
25
26 if (trait_exists($className)) {
27 return new self(
28 sprintf('The provided type "%s" is a trait, and cannot be instantiated', $className)
29 );
30 }
31
32 return new self(sprintf('The provided class "%s" does not exist', $className));
33 }
34
35 /**
36 * @phpstan-param ReflectionClass<T> $reflectionClass
37 *
38 * @template T of object
39 */
40 public static function fromAbstractClass(ReflectionClass $reflectionClass): self
41 {
42 return new self(sprintf(
43 'The provided class "%s" is abstract, and cannot be instantiated',
44 $reflectionClass->getName()
45 ));
46 }
47
48 public static function fromEnum(string $className): self
49 {
50 return new self(sprintf(
51 'The provided class "%s" is an enum, and cannot be instantiated',
52 $className
53 ));
54 }
55 }
56