Completed
Pull Request — staging (#840)
by
unknown
15:23
created

InvalidURI   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A from_uri() 0 8 1
A from_list() 0 9 1
A from_asset_path() 0 8 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 InvalidURI.
14
 *
15
 * @since   %VERSION%
16
 *
17
 * @package YIKES\EasyForms\Exception
18
 * @author  Freddie Mixell
19
 */
20
class InvalidURI extends \InvalidArgumentException implements Exception {
21
22
	/**
23
	 * Create a new instance of the exception for a file that is not accessible
24
	 * or not readable.
25
	 *
26
	 * @since %VERSION%
27
	 *
28
	 * @param string $uri URI of the file that is not accessible or not
29
	 *                    readable.
30
	 *
31
	 * @return static
32
	 */
33
	public static function from_uri( $uri ) {
34
		$message = sprintf(
35
			'The View URI "%s" is not accessible or readable.',
36
			$uri
37
		);
38
39
		return new static( $message );
40
	}
41
42
	/**
43
	 * Create a new instance of the exception for a file that is not in the list.
44
	 *
45
	 * @since %VERSION%
46
	 *
47
	 * @param string $uri  The invalid URI.
48
	 * @param array  $list The list of valid URIs.
49
	 *
50
	 * @return InvalidURI
51
	 */
52
	public static function from_list( $uri, array $list ) {
53
		$message = sprintf(
54
			'The View URI "%1$s" is not one of the valid options: [%2$s]',
55
			$uri,
56
			join( ', ', $list )
57
		);
58
59
		return new static( $message );
60
	}
61
62
	/**
63
	 * Create a new instance of the exception for a path that is invalid.
64
	 *
65
	 * @since %VERSION%
66
	 *
67
	 * @param string $path The path that is invalid.
68
	 *
69
	 * @return static
70
	 */
71
	public static function from_asset_path( $path ) {
72
		$message = sprintf(
73
			'The path "%s" is not readable. Do you need to run gulp?',
74
			$path
75
		);
76
77
		return new static( $message );
78
	}
79
}
80