Completed
Push — 4.0 ( dad14c...40f637 )
by Olivier
02:19
created

UserHasNoOwnership::get_resource()   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
 * @property-read User $user
19
 * @property-read mixed $resource
20
 */
21
class UserHasNoOwnership extends \Exception
22
{
23
	use AccessorTrait;
24
25
	const DEFAULT_MESSAGE = 'User has no ownership of the resource.';
26
27
	/**
28
	 * @var User
29
	 */
30
	private $user;
31
32
	/**
33
	 * @return User
34
	 */
35
	protected function get_user()
36
	{
37
		return $this->user;
38
	}
39
40
	/**
41
	 * @var mixed
42
	 */
43
	private $resource;
44
45
	/**
46
	 * @return mixed
47
	 */
48
	protected function get_resource()
49
	{
50
		return $this->resource;
51
	}
52
53
	/**
54
	 * @param User $user
55
	 * @param mixed $resource
56
	 * @param string $message
57
	 * @param \Exception|null $previous
58
	 */
59
	public function __construct(User $user, $resource, $message = self::DEFAULT_MESSAGE, \Exception $previous = null)
60
	{
61
		$this->user = $user;
62
		$this->resource = $resource;
63
64
		parent::__construct($message, Status::FORBIDDEN, $previous);
65
	}
66
}
67