Issues (2)

src/Three.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace LVR\CountryCode;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use League\ISO3166\Exception\DomainException;
7
use League\ISO3166\Exception\InvalidArgumentException;
0 ignored issues
show
The type League\ISO3166\Exception\InvalidArgumentException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use League\ISO3166\Exception\OutOfBoundsException;
9
use League\ISO3166\ISO3166;
10
11
class Three implements Rule
12
{
13
14
    /**
15
     * Determine if the validation rule passes.
16
     *
17
     * @param  string $attribute
18
     * @param  mixed  $value
19
     *
20
     * @return bool
21
     */
22 1
    public function passes($attribute, $value)
23
    {
24
        try {
25 1
            (new ISO3166)->alpha3($value);
26
27 1
            return true;
28 1
        } catch (DomainException | InvalidArgumentException | OutOfBoundsException $exception) {
29 1
            return false;
30
        }
31
    }
32
33
    /**
34
     * Get the validation error message.
35
     *
36
     * @return string
37
     */
38 1
    public function message()
39
    {
40 1
        return 'Invalid ISO3166-A3 country code.';
41
    }
42
}
43