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   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 8
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 63
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getTitle() 0 4 1
A getPayload() 0 4 1
A jsonSerialize() 0 8 1
A validateElement() 0 10 4
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
}