SetTrait::addEdges()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the bisarca/graph package.
5
 *
6
 * (c) Emanuele Minotto <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bisarca\Graph\Edge;
13
14
/**
15
 * ...
16
 */
17
trait SetTrait
18
{
19
    abstract public function getEdgeSet(): Set;
20
21
    /**
22
     * Sets the contained edges.
23
     *
24
     * @param EdgeInterface[] $edges
25
     */
26
    public function setEdges(EdgeInterface ...$edges)
27
    {
28
        $this
29
            ->getEdgeSet()
30
            ->set(...$edges);
31
    }
32
33
    /**
34
     * Adds some edges.
35
     *
36
     * @param EdgeInterface[] $edges
37
     */
38
    public function addEdges(EdgeInterface ...$edges)
39
    {
40
        $this
41
            ->getEdgeSet()
42
            ->add(...$edges);
43
    }
44
45
    /**
46
     * Checks if all the edges are contained.
47
     *
48
     * @param EdgeInterface[] $edges
49
     *
50
     * @return bool
51
     */
52
    public function hasEdges(EdgeInterface ...$edges): bool
53
    {
54
        return $this
55
            ->getEdgeSet()
56
            ->has(...$edges);
57
    }
58
59
    /**
60
     * Removes some edges.
61
     *
62
     * @param EdgeInterface[] $edges
63
     */
64
    public function removeEdges(EdgeInterface ...$edges)
65
    {
66
        $this
67
            ->getEdgeSet()
68
            ->remove(...$edges);
69
    }
70
71
    /**
72
     * Remove all contained elements.
73
     */
74
    public function clearEdges()
75
    {
76
        $this
77
            ->getEdgeSet()
78
            ->clear();
79
    }
80
81
    /**
82
     * Checks if no elements are contained.
83
     *
84
     * @return bool
85
     */
86
    public function isEmptyEdges(): bool
87
    {
88
        return $this
89
            ->getEdgeSet()
90
            ->isEmpty();
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function countEdges(): int
97
    {
98
        return $this
99
            ->getEdgeSet()
100
            ->count();
101
    }
102
}
103