ClientCommon   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getWarnings() 0 5 2
A getClientName() 0 6 2
A getClientTitle() 0 6 2
1
<?php
2
3
namespace BiffBangPow\SSMonitor\Server\Client;
4
5
use SilverStripe\Core\Extensible;
6
7
trait ClientCommon
8
{
9
    use Extensible;
10
11
    /**
12
     * Get the client name/identifier for this client module
13
     * @return string
14
     * @throws \Exception
15
     */
16
    public function getClientName(): string
17
    {
18
        if ($this->clientName === '') {
19
            throw new \Exception("No client name defined for monitoring client");
20
        }
21
        return $this->clientName;
22
    }
23
24
    /**
25
     * Get the friendly name for this client module
26
     * @return string
27
     * @throws \Exception
28
     */
29
    public function getClientTitle(): string
30
    {
31
        if ($this->config()->get('client_title')) {
0 ignored issues
show
Bug introduced by
The method config() does not exist on BiffBangPow\SSMonitor\Server\Client\ClientCommon. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

31
        if ($this->/** @scrutinizer ignore-call */ config()->get('client_title')) {
Loading history...
32
            return $this->config()->get('client_title');
33
        }
34
        return $this->getClientName();
35
    }
36
37
    /**
38
     * Get an array of warning messages
39
     * @param $data
40
     * @return array|false
41
     */
42
    public function getWarnings($data)
43
    {
44
        $allWarnings = [];
45
        $this->extend('updateWarnings', $allWarnings, $data);
46
        return (count($allWarnings) > 0) ? $allWarnings : false;
47
    }
48
}
49