Issues (30)

src/Client/ClientCommon.php (1 issue)

Labels
Severity
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
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