Collection   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getBySsid() 0 3 1
A getConnected() 0 3 1
A getByBssid() 0 3 1
A firstOrFail() 0 7 2
A getAll() 0 3 1
1
<?php
2
3
namespace Sanchescom\WiFi\System;
4
5
use Sanchescom\WiFi\Exceptions\NetworkNotFoundException;
6
use Tightenco\Collect\Support\Collection as BaseCollection;
7
8
/**
9
 * Class Collection.
10
 */
11
class Collection extends BaseCollection
12
{
13
    /**
14
     * @return \Sanchescom\WiFi\System\AbstractNetwork[]
15
     */
16
    public function getAll()
17
    {
18
        return $this->all();
19
    }
20
21
    /**
22
     * @param string $ssid
23
     *
24
     * @return \Sanchescom\WiFi\System\AbstractNetwork
25
     */
26
    public function getBySsid(string $ssid)
27
    {
28
        return $this->where('ssid', $ssid)->firstOrFail();
29
    }
30
31
    /**
32
     * @param string $bssid
33
     *
34
     * @return \Sanchescom\WiFi\System\AbstractNetwork
35
     */
36
    public function getByBssid(string $bssid)
37
    {
38
        return $this->where('bssid', $bssid)->firstOrFail();
39
    }
40
41
    /**
42
     * @return \Sanchescom\WiFi\System\AbstractNetwork[]
43
     */
44
    public function getConnected()
45
    {
46
        return $this->where('connected', true)->all();
47
    }
48
49
    /**
50
     * @throws \Sanchescom\WiFi\Exceptions\NetworkNotFoundException
51
     *
52
     * @return \Sanchescom\WiFi\System\AbstractNetwork
53
     */
54
    public function firstOrFail()
55
    {
56
        if ($this->isEmpty()) {
57
            throw new NetworkNotFoundException();
58
        }
59
60
        return $this->first();
61
    }
62
}
63