ClientCommon   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getClientName() 0 6 2
A getClientTitle() 0 6 2
1
<?php
2
3
namespace BiffBangPow\SSMonitor\Client\Core;
4
5
trait ClientCommon
6
{
7
8
    /**
9
     * Get the client name/identifier for this client module
10
     * @return string
11
     * @throws \Exception
12
     */
13
    public function getClientName(): string
14
    {
15
        if ($this->clientName === '') {
16
            throw new \Exception("No client name defined for monitoring client");
17
        }
18
        return $this->clientName;
19
    }
20
21
    /**
22
     * Get the friendly name for this client module
23
     * @return string
24
     * @throws \Exception
25
     */
26
    public function getClientTitle(): string
27
    {
28
        if ($this->config()->get('client_title')) {
0 ignored issues
show
Bug introduced by
It seems like config() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

28
        if ($this->/** @scrutinizer ignore-call */ config()->get('client_title')) {
Loading history...
29
            return $this->config()->get('client_title');
30
        }
31
        return $this->getClientName();
32
    }
33
34
}
35