Completed
Pull Request — master (#154)
by
unknown
05:50 queued 01:40
created

DocumentNotFoundException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A fromClassNameAndIdentifier() 0 12 2
1
<?php
2
3
namespace Doctrine\ODM\CouchDB;
4
5
use Doctrine\ORM\EntityNotFoundException;
6
7
/**
8
 * Exception thrown when a Proxy fails to retrieve a Document.
9
 *
10
 * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
11
 * @link        www.doctrine-project.com
12
 * @since       1.0
13
 * @author      Nils Adermann <[email protected]>
14
 */
15
class DocumentNotFoundException extends CouchDBException
16
{
17
    public function __construct($message = null)
18
    {
19
        parent::__construct($message ?? 'Document was not found.');
20
    }
21
22
	/**
23
	 * Static constructor.
24
	 *
25
	 * @param string  $className
26
	 * @param mixed $id
27
	 *
28
	 * @return self
29
	 */
30
	public static function fromClassNameAndIdentifier($className, $id)
31
	{
32
		$ids = [];
33
34
		foreach ($id as $key => $value) {
35
			$ids[] = $key . '(' . $value . ')';
36
		}
37
38
		return new self(
39
			'Document of type \'' . $className . '\' for ID ' .  $id . ' was not found'
40
		);
41
	}
42
}
43