Completed
Pull Request — staging (#840)
by
unknown
17:14
created

InvalidKey::empty_key()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * YIKES Inc. Easy Mailchimp Forms Plugin.
4
 *
5
 * @package   YIKES\EasyForms
6
 * @author    Freddie Mixell
7
 * @license   GPL2
8
 */
9
10
namespace YIKES\EasyForms\Exception;
11
12
/**
13
 * Class InvalidKey
14
 *
15
 * @since   %VERSION%
16
 * @package YIKES\EasyForms
17
 */
18
class InvalidKey extends \InvalidArgumentException implements Exception {
19
20
	/**
21
	 * Create a new instance of an exception when an empty key is provided.
22
	 *
23
	 * @since %VERSION%
24
	 *
25
	 * @param string $function The name of the calling function or method.
26
	 *
27
	 * @return InvalidKey
28
	 */
29
	public static function empty_key( $function ) {
30
		$message = sprintf( 'The key for "%s" cannot be empty.', $function );
31
32
		return new static( $message );
33
	}
34
35
	/**
36
	 * Create a new instance of an exception when a key is not found for the function.
37
	 *
38
	 * @since %VERSION%
39
	 *
40
	 * @param string $key      The key that wasn't found.
41
	 * @param string $function The function where the key isn't found.
42
	 *
43
	 * @return static
44
	 */
45
	public static function not_found( $key, $function ) {
46
		$message = sprintf( 'The key "%s" was not found for function "%s".', $key, $function );
47
48
		return new static( $message );
49
	}
50
}
51