• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chdemko / php-sorted-collections / 12390158994

18 Dec 2024 09:33AM UTC coverage: 100.0%. Remained the same
12390158994

push

github

chdemko
Fix style in benchmarks

754 of 754 relevant lines covered (100.0%)

113.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/SortedCollection/ReversedSet.php
1
<?php
2

3
/**
4
 * chdemko\SortedCollection\ReversedSet class
5
 *
6
 * @author    Christophe Demko <chdemko@gmail.com>
7
 * @copyright Copyright (C) 2012-2024 Christophe Demko. All rights reserved.
8
 *
9
 * @license BSD 3-Clause License
10
 *
11
 * This file is part of the php-sorted-collections package https://github.com/chdemko/php-sorted-collections
12
 */
13

14
// Declare chdemko\SortedCollection namespace
15
namespace chdemko\SortedCollection;
16

17
/**
18
 * Reversed set
19
 *
20
 * @package    SortedCollection
21
 * @subpackage Set
22
 *
23
 * @since 1.0.0
24
 *
25
 * @property-read callable   $comparator  The element comparison function
26
 * @property-read mixed      $first       The first element of the set
27
 * @property-read mixed      $last        The last element of the set
28
 * @property-read integer    $count       The number of elements in the set
29
 * @property-read SortedSet  $set         The underlying set
30
 */
31
class ReversedSet extends AbstractSet
32
{
33
    /**
34
     * @var SortedSet  Internal set
35
     *
36
     * @since 1.0.0
37
     */
38
    private $set;
39

40
    /**
41
     * Constructor
42
     *
43
     * @param SortedSet $set Internal set
44
     *
45
     * @since 1.0.0
46
     */
47
    protected function __construct(SortedSet $set)
48
    {
49
        $this->setMap(ReversedMap::create($set->getMap()))->set = $set;
7✔
50
    }
51

52
    /**
53
     * Create
54
     *
55
     * @param SortedSet $set Internal set
56
     *
57
     * @return ReversedSet A new reversed set
58
     *
59
     * @since 1.0.0
60
     */
61
    public static function create(SortedSet $set)
62
    {
63
        return new static($set);
7✔
64
    }
65

66
    /**
67
     * Magic get method
68
     *
69
     * @param string $property The property
70
     *
71
     * @return mixed The value associated to the property
72
     *
73
     * @since 1.0.0
74
     */
75
    public function __get($property)
76
    {
77
        switch ($property) {
78
            case 'set':
1✔
79
                return $this->set;
1✔
80
            default:
81
                return parent::__get($property);
1✔
82
        }
83
    }
84

85
    /**
86
     * Serialize the object
87
     *
88
     * @return array Array of values
89
     *
90
     * @since 1.0.0
91
     */
92
    public function jsonSerialize(): array
93
    {
94
        return array('ReversedSet' => $this->set->jsonSerialize());
1✔
95
    }
96
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc