ReadException::forException()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the webmozart/key-value-store package.
5
 *
6
 * (c) Bernhard Schussek <[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 Webmozart\KeyValueStore\Api;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Thrown when a key-value store cannot be read.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class ReadException extends RuntimeException
25
{
26
    /**
27
     * Creates a new exception..
28
     *
29
     * @param Exception $exception The exception that caused this exception.
30
     *
31
     * @return static The new exception.
32
     */
33 54
    public static function forException(Exception $exception)
34
    {
35 54
        return new static(sprintf(
36 54
            'Could not read key-value store: %s',
37 54
            $exception->getMessage()
38 54
        ), $exception->getCode(), $exception);
39
    }
40
}
41