• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 12673986434

08 Jan 2025 03:42PM UTC coverage: 84.455% (+0.001%) from 84.454%
12673986434

Pull #9385

github

web-flow
Merge 06e47f0ee into e475fd8fa
Pull Request #9385: refactor: Fix phpstan expr.resultUnused

20699 of 24509 relevant lines covered (84.45%)

190.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/system/Exceptions/PageNotFoundException.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Exceptions;
15

16
class PageNotFoundException extends RuntimeException implements HTTPExceptionInterface
17
{
18
    use DebugTraceableTrait;
19

20
    /**
21
     * HTTP status code
22
     *
23
     * @var int
24
     */
25
    protected $code = 404;
26

27
    /**
28
     * @return static
29
     */
30
    public static function forPageNotFound(?string $message = null)
31
    {
32
        return new static($message ?? self::lang('HTTP.pageNotFound'));
8✔
33
    }
34

35
    /**
36
     * @return static
37
     */
38
    public static function forEmptyController()
39
    {
40
        return new static(self::lang('HTTP.emptyController'));
×
41
    }
42

43
    /**
44
     * @return static
45
     */
46
    public static function forControllerNotFound(string $controller, string $method)
47
    {
48
        return new static(self::lang('HTTP.controllerNotFound', [$controller, $method]));
5✔
49
    }
50

51
    /**
52
     * @return static
53
     */
54
    public static function forMethodNotFound(string $method)
55
    {
56
        return new static(self::lang('HTTP.methodNotFound', [$method]));
×
57
    }
58

59
    /**
60
     * @return static
61
     */
62
    public static function forLocaleNotSupported(string $locale)
63
    {
64
        return new static(self::lang('HTTP.localeNotSupported', [$locale]));
1✔
65
    }
66

67
    /**
68
     * Get translated system message
69
     *
70
     * Use a non-shared Language instance in the Services.
71
     * If a shared instance is created, the Language will
72
     * have the current locale, so even if users call
73
     * `$this->request->setLocale()` in the controller afterwards,
74
     * the Language locale will not be changed.
75
     */
76
    private static function lang(string $line, array $args = []): string
77
    {
78
        $lang = service('language', null, false);
7✔
79

80
        return $lang->getLine($line, $args);
7✔
81
    }
82
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc