Completed
Pull Request — staging (#840)
by
unknown
16:26
created

FailedToLoadView::view_exception()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 9
rs 9.9666
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 FailedToLoadView.
14
 *
15
 * @since   %VERSION%
16
 *
17
 * @package YIKES\EasyForms\Exception
18
 * @author  Freddie Mixell
19
 */
20
class FailedToLoadView extends \RuntimeException implements Exception {
21
22
	/**
23
	 * Create a new instance of the exception if the view file itself created
24
	 * an exception.
25
	 *
26
	 * @since %VERSION%
27
	 *
28
	 * @param string     $uri       URI of the file that is not accessible or
29
	 *                              not readable.
30
	 * @param \Exception $exception Exception that was thrown by the view file.
31
	 *
32
	 * @return static
33
	 */
34
	public static function view_exception( $uri, $exception ) {
35
		$message = sprintf(
36
			'Could not load the View URI "%1$s". Reason: "%2$s".',
37
			$uri,
38
			$exception->getMessage()
39
		);
40
41
		return new static( $message, $exception->getCode(), $exception );
42
	}
43
}
44