Completed
Pull Request — master (#447)
by Marcel
03:00 queued 01:29
created

AppId::message()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BeyondCode\LaravelWebSockets\Rules;
4
5
use BeyondCode\LaravelWebSockets\Contracts\AppManager;
6
use Illuminate\Contracts\Validation\Rule;
7
8
class AppId implements Rule
9
{
10
    /**
11
     * Create a new rule.
12
     *
13
     * @param  mixed  $attribute
14
     * @param  mixed  $value
15
     * @return bool
16
     */
17
    public function passes($attribute, $value)
18
    {
19
        $manager = app(AppManager::class);
20
21
        return $manager->findById($value) ? true : false;
22
    }
23
24
    /**
25
     * The validation message.
26
     *
27
     * @return string
28
     */
29
    public function message()
30
    {
31
        return 'There is no app registered with the given id. Make sure the websockets config file contains an app for this id or that your custom AppManager returns an app for this id.';
32
    }
33
}
34