Skip to content
Snippets Groups Projects

3395876-Implement the whereStrict method for Collection class

1 file
+ 18
0
Compare changes
  • Side-by-side
  • Inline
+ 18
0
@@ -74,4 +74,22 @@ class Collection extends BaseCollection {
};
}
/**
* Filter items using strict comparison.
*
* @param string $key
* @param mixed $value
* @return \Drupal\fluent\Collection
*/
public function whereStrict($key, $value)
{
return $this->filter(function ($item) use ($key, $value) {
if ($item instanceof ContentEntityInterface) {
return using($item)->value($key) === $value;
} else {
return data_get($item, $key) === $value;
}
});
}
}
Loading