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

TooManyItems   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A from_post_type() 0 15 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 TooManyItems
14
 *
15
 * @since   %VERSION%
16
 * @package Yikes\EasyForms
17
 */
18
class TooManyItems extends \InvalidArgumentException implements Exception {
19
20
	/**
21
	 * Create a new exception instance for a post type that is limited.
22
	 *
23
	 * @since %VERSION%
24
	 *
25
	 * @param string $post_type The post type.
26
	 * @param int    $limit     The limit for the post type.
27
	 *
28
	 * @return static
29
	 */
30
	public static function from_post_type( $post_type, $limit ) {
31
		$message = sprintf(
32
			/* translators: %1$s is the post type, %2$d is the item limit */
33
			_n(
34
				'%1$s do not support more than %2$d item.',
35
				'%1$s do not support more than %2$d items.',
36
				$limit,
37
				'yikes-inc-easy-mailchimp-extender'
38
			),
39
			$post_type,
40
			$limit
41
		);
42
43
		return new static( $message );
44
	}
45
}
46