Completed
Push — 4.0 ( af9dea...2073b3 )
by Olivier
03:18 queued 55s
created

UserLacksPermission::get_user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Icybee package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Icybee\Modules\Users;
13
14
use ICanBoogie\Accessor\AccessorTrait;
15
use ICanBoogie\HTTP\Status;
16
17
/**
18
 * Exception thrown when a user lacks a required permission.
19
 *
20
 * @property-read User $user
21
 * @property-read string|int $permission
22
 * @property-read mixed|null $resource
23
 */
24
class UserLacksPermission extends \Exception
25
{
26
	use AccessorTrait;
27
28
	const DEFAULT_MESSAGE = 'User lacks the required permission.';
29
30
	/**
31
	 * @var User
32
	 */
33
	private $user;
34
35
	/**
36
	 * @return User
37
	 */
38
	protected function get_user()
39
	{
40
		return $this->user;
41
	}
42
43
	/**
44
	 * @var mixed
45
	 */
46
	private $permission;
47
48
	/**
49
	 * @return string|int
50
	 */
51
	protected function get_permission()
52
	{
53
		return $this->permission;
54
	}
55
56
	/**
57
	 * @var mixed
58
	 */
59
	private $resource;
60
61
	/**
62
	 * @return mixed
63
	 */
64
	protected function get_resource()
65
	{
66
		return $this->resource;
67
	}
68
69
	/**
70
	 * @param User $user
71
	 * @param string|int $permission
72
	 * @param mixed $resource
73
	 * @param string $message
74
	 * @param \Exception|null $previous
75
	 */
76 View Code Duplication
	public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
77
		User $user,
78
		$permission,
79
		$resource = null,
80
		$message = self::DEFAULT_MESSAGE,
81
		\Exception $previous = null
82
	) {
83
		$this->user = $user;
84
		$this->permission = $permission;
85
		$this->resource = $resource;
86
87
		parent::__construct($message, Status::FORBIDDEN, $previous);
88
	}
89
}
90