Completed
Push — ezp26175-exception_on_non_defa... ( 896160...624e06 )
by
unknown
31:45
created

NotFoundHttpException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 3
dl 7
loc 7
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the eZ Publish Kernel package.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\Base\Exceptions;
10
11
use Exception;
12
use eZ\Publish\Core\Base\Translatable;
13
use eZ\Publish\Core\Base\TranslatableBase;
14
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException as SymfonyNotFoundHttpException;
15
16
/**
17
 * A translatable Not Found HTTP Exception implementation.
18
 *
19
 * Use:
20
 *   throw new NotFoundHttpException( 'Content', 42 );
21
 */
22 View Code Duplication
class NotFoundHttpException extends SymfonyNotFoundHttpException implements Translatable
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
{
24
    use TranslatableBase;
25
26
    /**
27
     * Generates: Could not find '{$what}' with identifier '{$identifier}'.
28
     *
29
     * @param string $what
30
     * @param mixed $identifier
31
     * @param \Exception|null $previous
32
     */
33
    public function __construct($what, $identifier, Exception $previous = null)
34
    {
35
        $identifierStr = is_string($identifier) ? $identifier : var_export($identifier, true);
36
        $this->setMessageTemplate("Could not find '%what%' with identifier '%identifier%'");
37
        $this->setParameters(['%what%' => $what, '%identifier%' => $identifierStr]);
38
        parent::__construct($this->getBaseTranslation(), $previous);
39
    }
40
}
41