PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 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 All 35 releases
media-cloud-sync / includes / sdk / google / ramsey / collection / src / AbstractSet.php

AbstractSet.php in Media Cloud Sync 1.4.1, at includes/sdk/google/ramsey/collection/src/AbstractSet.php

46 lines 1.4 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\GCP\Ramsey\Collection;
14
15 /**
16 * This class contains the basic implementation of a collection that does not
17 * allow duplicated values (a set), to minimize the effort required to implement
18 * this specific type of collection.
19 *
20 * @template T
21 * @extends AbstractCollection<T>
22 */
23 abstract class AbstractSet extends AbstractCollection
24 {
25 public function add(mixed $element) : bool
26 {
27 if ($this->contains($element)) {
28 return \false;
29 }
30 // Call offsetSet() on the parent instead of add(), since calling
31 // parent::add() will invoke $this->offsetSet(), which will call
32 // $this->contains() a second time. This can cause performance issues
33 // with extremely large collections. For more information, see
34 // https://github.com/ramsey/collection/issues/68.
35 parent::offsetSet(null, $element);
36 return \true;
37 }
38 public function offsetSet(mixed $offset, mixed $value) : void
39 {
40 if ($this->contains($value)) {
41 return;
42 }
43 parent::offsetSet($offset, $value);
44 }
45 }
46