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

UserHasNoOwnership   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_user() 0 4 1
A get_resource() 0 4 1
A __construct() 0 7 1
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