Passed
Pull Request — master (#5)
by Aleksandr
02:53
created

Collection::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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 AbstractNetwork[]
15
     */
16
    public function getAll()
17
    {
18
        return $this->all();
19
    }
20
21
    /**
22
     * @param $ssid
23
     *
24
     * @return AbstractNetwork
25
     */
26
    public function getBySsid($ssid)
27
    {
28
        return $this->where('ssid', $ssid)->firstOrFail();
29
    }
30
31
    /**
32
     * @param string $bssid
33
     *
34
     * @return AbstractNetwork
35
     */
36
    public function getByBssid(string $bssid)
37
    {
38
        return $this->where('bssid', $bssid)->firstOrFail();
39
    }
40
41
    /**
42
     * @return AbstractNetwork[]
43
     */
44
    public function getConnected()
45
    {
46
        return $this->where('connected', true)->all();
47
    }
48
49
    /**
50
     * @throws NetworkNotFoundException
51
     *
52
     * @return AbstractNetwork
53
     */
54
    public function firstOrFail()
55
    {
56
        if ($this->isEmpty()) {
57
            throw new NetworkNotFoundException();
58
        }
59
60
        return $this->first();
61
    }
62
}
63