Completed
Pull Request — staging (#840)
by
unknown
18:30
created

InvalidKey   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A empty_key() 0 5 1
A not_found() 0 5 1
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