PluginProbe
Media Cloud Sync / 1.2.4
Media Cloud Sync v1.2.4
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / sdk / google / ramsey / collection / src / Set.php

Set.php in Media Cloud Sync 1.2.4, at includes/sdk/google/ramsey/collection/src/Set.php

64 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the ramsey/collection library
5 *
6 * For the full copyright and license information, please view the LICENSE
7 * file that was distributed with this source code.
8 *
9 * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
10 * @license http://opensource.org/licenses/MIT MIT
11 */
12 declare (strict_types=1);
13 namespace Dudlewebs\WPMCS\Ramsey\Collection;
14
15 /**
16 * A set is a collection that contains no duplicate elements.
17 *
18 * Great care must be exercised if mutable objects are used as set elements.
19 * The behavior of a set is not specified if the value of an object is changed
20 * in a manner that affects equals comparisons while the object is an element in
21 * the set.
22 *
23 * Example usage:
24 *
25 * ``` php
26 * $foo = new \My\Foo();
27 * $set = new Set(\My\Foo::class);
28 *
29 * $set->add($foo); // returns TRUE, the element don't exists
30 * $set->add($foo); // returns FALSE, the element already exists
31 *
32 * $bar = new \My\Foo();
33 * $set->add($bar); // returns TRUE, $bar !== $foo
34 * ```
35 *
36 * @template T
37 * @extends AbstractSet<T>
38 */
39 class Set extends AbstractSet
40 {
41 /**
42 * The type of elements stored in this set
43 *
44 * A set's type is immutable. For this reason, this property is private.
45 */
46 private string $setType;
47 /**
48 * Constructs a set object of the specified type, optionally with the
49 * specified data.
50 *
51 * @param string $setType The type (FQCN) associated with this set.
52 * @param array<array-key, T> $data The initial items to store in the set.
53 */
54 public function __construct(string $setType, array $data = [])
55 {
56 $this->setType = $setType;
57 parent::__construct($data);
58 }
59 public function getType(): string
60 {
61 return $this->setType;
62 }
63 }
64