Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Exception
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __toString
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * phpMyFAQ main exception class.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2009-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2009-12-28
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Core;
21
22/**
23 * Class Exception
24 *
25 * @package phpMyFAQ
26 */
27class Exception extends \Exception implements \Stringable
28{
29    /**
30     * Converts Exception to a string.
31     */
32    public function __toString(): string
33    {
34        return sprintf(
35            "Exception %s with message %s in %s: %s\nStack trace:\n%s",
36            self::class,
37            $this->getMessage(),
38            $this->getFile(),
39            $this->getLine(),
40            $this->getTraceAsString(),
41        );
42    }
43}