Passed
Pull Request — 2.6 (#7716)
by
unknown
06:45
created

CacheSetupException::autoSetupFailed()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 14
ccs 0
cts 14
cp 0
crap 6
rs 9.9
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace Doctrine\ORM\Tools;
21
22
/**
23
 * A custom exception for handling failures during cache configuration from Doctrine\ORM\Tools\Setup
24
 *
25
 * @author Paul Court <[email protected]>
26
 */
27
class CacheSetupException extends \Doctrine\ORM\ORMException
28
{
29
    
30
    public static function autoSetupFailed(\Throwable $previous = null)
31
    {
32
        $code = 0;
33
        if ($previous !== null) {
34
            $code = $previous->getCode();
35
        }
36
        return new self(""
37
                . "An attempt to automatically create a cache instance failed! - The most "
38
                . "likely cause is the presence of a supported extension (apcu, memcached or "
39
                . "redis) but no matching service running locally on 127.0.0.1. The best way"
40
                . "to fix this is to manually create a cache instance and pass it to the "
41
                . "Doctrine\ORM\Tools\Setup method that you are trying to use.", 
42
                $code, 
43
                $previous);
44
    }
45
}
46