Skip to content

Commit

Permalink
Replace Only with IntersectKeys operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Sep 8, 2020
1 parent 841a7c5 commit 78a20a3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 95 deletions.
19 changes: 8 additions & 11 deletions spec/loophp/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -838,17 +838,6 @@ public function it_can_get_current()
->shouldReturn(null);
}

public function it_can_get_items_with_only_specific_keys(): void
{
$this::fromIterable(range('A', 'E'))
->only(0, 1, 3)
->shouldIterateAs([0 => 'A', 1 => 'B', 3 => 'D']);

$this::fromIterable(range('A', 'E'))
->only()
->shouldIterateAs([0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D', 4 => 'E']);
}

public function it_can_get_key()
{
$input = array_combine(range('A', 'E'), range('A', 'E'));
Expand Down Expand Up @@ -1067,6 +1056,14 @@ public function it_can_intersectKeys(): void
$this::fromIterable($input)
->intersectKeys()
->shouldIterateAs([]);

$this::fromIterable(range('A', 'E'))
->intersectKeys(0, 1, 3)
->shouldIterateAs([0 => 'A', 1 => 'B', 3 => 'D']);

$this::fromIterable(range('A', 'E'))
->intersectKeys()
->shouldIterateAs([]);
}

public function it_can_intersperse(): void
Expand Down
6 changes: 0 additions & 6 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
use loophp\collection\Operation\Normalize;
use loophp\collection\Operation\Nth;
use loophp\collection\Operation\Nullsy;
use loophp\collection\Operation\Only;
use loophp\collection\Operation\Pack;
use loophp\collection\Operation\Pad;
use loophp\collection\Operation\Pair;
Expand Down Expand Up @@ -563,11 +562,6 @@ public function nullsy(): bool
return $this->run(Nullsy::of())->getIterator()->current();
}

public function only(...$keys): CollectionInterface
{
return $this->run(Only::of()(...$keys));
}

public function pack(): CollectionInterface
{
return $this->run(Pack::of());
Expand Down
3 changes: 0 additions & 3 deletions src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
use loophp\collection\Contract\Operation\Normalizeable;
use loophp\collection\Contract\Operation\Nthable;
use loophp\collection\Contract\Operation\Nullsyable;
use loophp\collection\Contract\Operation\Onlyable;
use loophp\collection\Contract\Operation\Packable;
use loophp\collection\Contract\Operation\Padable;
use loophp\collection\Contract\Operation\Pairable;
Expand Down Expand Up @@ -139,7 +138,6 @@
* @template-extends Mergeable<TKey, T>
* @template-extends Normalizeable<TKey, T>
* @template-extends Nthable<TKey, T>
* @template-extends Onlyable<TKey, T>
* @template-extends Packable<TKey, T>
* @template-extends Padable<TKey, T>
* @template-extends Pairable<TKey, T>
Expand Down Expand Up @@ -223,7 +221,6 @@ interface Collection extends
Normalizeable,
Nthable,
Nullsyable,
Onlyable,
Packable,
Padable,
Pairable,
Expand Down
24 changes: 0 additions & 24 deletions src/Contract/Operation/Onlyable.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/Operation/Only.php

This file was deleted.

0 comments on commit 78a20a3

Please sign in to comment.