Completed
Pull Request — staging (#840)
by
unknown
19:58
created

FailedToSavePost   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A from_type() 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 FailedToSavePost
14
 *
15
 * @since   %VERSION%
16
 * @package YIKES\EasyForms
17
 */
18
class FailedToSavePost extends \RuntimeException implements Exception {
19
20
	/**
21
	 * Creat a new instance of the exception if we failed to save a post.
22
	 *
23
	 * @since %VERSION%
24
	 *
25
	 * @param string $type   The post type that failed to save.
26
	 * @param string $reason The reason the save failed.
27
	 *
28
	 * @return static
29
	 */
30
	public static function from_type( $type, $reason ) {
31
		$message = sprintf( 'Error saving %1$s. Reason: %2$s', $type, $reason );
32
33
		return new static( $message );
34
	}
35
}
36