GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#8)
by
unknown
04:06
created

Text::validateElement()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
rs 9.2
cc 4
eloc 5
nc 3
nop 0
1
<?php
2
3
namespace Tgallice\FBMessenger\Model\QuickReplies;
4
5
class Text implements \JsonSerializable
6
{
7
	/**
8
	 * @var string
9
	 */
10
	private $title;
11
12
	/**
13
	 * @var string
14
	 */
15
	private $payload;
16
17
	/**
18
	 * @param string $title
19
	 * @param string $payload
20
	 */
21
	public function __construct($title, $payload)
22
	{
23
		$this->title = $title;
24
		$this->payload = $payload;
25
26
		$this->validateElement();
27
	}
28
29
	/**
30
	 * @return string
31
	 */
32
	public function getTitle()
33
	{
34
		return $this->title;
35
	}
36
37
	/**
38
	 * @return string
39
	 */
40
	public function getPayload()
41
	{
42
		return $this->payload;
43
	}
44
45
	/**
46
	 * @return array
47
	 */
48
	public function jsonSerialize()
49
	{
50
		return [
51
			'content_type' => 'text',
52
			'title' => $this->title,
53
			'payload' => $this->payload
54
		];
55
	}
56
57
	private function validateElement()
58
	{
59
		if (mb_strlen($this->title) > 20) {
60
			throw new \InvalidArgumentException('The "title" field should not exceed 20 characters');
61
		}
62
63
		if (!empty($this->payload) && mb_strlen($this->payload) > 1000) {
64
			throw new \InvalidArgumentException('The "payload" field should not exceed 1000 characters');
65
		}
66
	}
67
}