-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathInvalidClass.php
68 lines (62 loc) · 1.59 KB
/
InvalidClass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Exception;
use LogicException;
/**
* Class InvalidClass
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Exception
*/
class InvalidClass extends LogicException implements GoogleListingsAndAdsException {
/**
* Create a new instance of the exception when a class should implement an interface but does not.
*
* @param string $class The class name.
* @param string $interface The interface name.
*
* @return static
*/
public static function should_implement( string $class, string $interface ) {
return new static(
sprintf(
'The class "%s" must implement the "%s" interface.',
$class,
$interface
)
);
}
/**
* Create a new instance of the exception when a class should NOT implement an interface but it does.
*
* @param string $class The class name.
* @param string $interface The interface name.
*
* @return static
*/
public static function should_not_implement( string $class, string $interface ): InvalidClass {
return new static(
sprintf(
'The class "%s" must NOT implement the "%s" interface.',
$class,
$interface
)
);
}
/**
* Create a new instance of the exception when a class should override a method but does not.
*
* @param string $class The class name.
* @param string $method The method name.
*
* @return static
*/
public static function should_override( string $class, string $method ) {
return new static(
sprintf(
'The class "%s" must override the "%s()" method.',
$class,
$method
)
);
}
}