Skip to content

Commit

Permalink
Update ::get() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed Aug 14, 2019
1 parent c9aff7b commit b78b672
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ $square = new class() extends Operation {
*/
public function run(CollectionInterface $collection): CollectionInterface
{
return $collection::withClosure(
return Collection::withClosure(
static function () use ($collection) {
foreach ($collection as $item) {
yield $item ** 2;
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"drupol/phpspec-annotation": "^1.2",
"drupol/phpspec-code-coverage": "^5",
"infection/infection": "^0.13",
"phpbench/phpbench": "^0.16.9",
"phpspec/phpspec": "^5",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11.1",
Expand All @@ -36,9 +37,14 @@
"drupol\\collection\\": "./src/"
}
},
"autoload-dev": {
"psr-4": {
"drupol\\collection\\benchmarks\\": "./benchmarks/"
}
},
"scripts": {
"apigen": "./vendor/bin/apigen generate src --destination build/docs",
"bench": "./vendor/bin/phpbench run --report=project --store --precision=3",
"bench": "./vendor/bin/phpbench run --report='generator: \"table\", cols: [ \"suite\", \"subject\", \"mean\", \"diff\", \"mem_peak\", \"mem_real\"], break: [\"benchmark\"]'",
"codacy": "./vendor/bin/codacycoverage clover build/logs/clover.xml",
"grumphp": "./vendor/bin/grumphp run",
"infection": "./vendor/bin/infection run -j 10",
Expand Down
4 changes: 0 additions & 4 deletions spec/drupol/collection/CollectionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,6 @@ public function it_can_get(): void
->get(4)
->shouldReturn('E');

$this
->get()
->shouldBeNull();

$this
->get('unexistent key', 'default')
->shouldReturn('default');
Expand Down
6 changes: 1 addition & 5 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,8 @@ public function forget(...$keys): CollectionInterface
/**
* {@inheritdoc}
*/
public function get($key = null, $default = null)
public function get($key, $default = null)
{
if (null === $key) {
return;
}

foreach ($this->getIterator() as $outerKey => $outerValue) {
if ($outerKey === $key) {
return $outerValue;
Expand Down
2 changes: 1 addition & 1 deletion src/Contract/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function forget(...$keys): self;
*
* @return mixed
*/
public function get($key = null, $default = null);
public function get($key, $default = null);

/**
* Get the values iterator.
Expand Down

0 comments on commit b78b672

Please sign in to comment.