ValidationMessages::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
/*
4
 * This file is part of persian validation package
5
 *
6
 * (c) Farhad Zand <[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 Iamfarhad\Validation;
13
14
use App;
15
16
class ValidationMessages
17
{
18
    /**
19
     * @var mixed lang
20
     */
21
    public $lang;
22
23
    /**
24
     * ValidationMessages constructor.
25
     */
26
    public function __construct()
27
    {
28
        $app_lang = resource_path('lang/validation/'.App::getLocale().'.php');
0 ignored issues
show
Bug introduced by
The function resource_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $app_lang = /** @scrutinizer ignore-call */ resource_path('lang/validation/'.App::getLocale().'.php');
Loading history...
29
30
        if (! file_exists($app_lang)) {
31
            $this->lang = include $app_lang;
32
        } else {
33
            $this->lang = include __DIR__.'/lang/validation/'.App::getLocale().'.php';
34
        }
35
    }
36
37
    /**
38
     * @param $message
39
     * @param $attribute
40
     * @param $rule
41
     * @return string
42
     */
43
    public function message($message, $attribute, $rule): string
0 ignored issues
show
Unused Code introduced by
The parameter $attribute is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

43
    public function message($message, /** @scrutinizer ignore-unused */ $attribute, $rule): string

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        return str_replace($message, $this->lang[$rule], $message);
46
    }
47
}
48