Completed
Pull Request — master (#447)
by Alexandru
01:35
created

AppId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 26
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A passes() 0 6 2
A message() 0 4 1
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