Skip to content

Commit

Permalink
Use array_wrap() in several places (#17276)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikazooz authored and taylorotwell committed Jan 11, 2017
1 parent 828fb21 commit 58078b8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ protected function createPdoResolverWithHosts(array $config)
*/
protected function parseHosts(array $config)
{
$hosts = is_array($config['host']) ? $config['host'] : [$config['host']];
$hosts = array_wrap($config['host']);

if (empty($hosts)) {
throw new InvalidArgumentException('Database hosts array is empty.');
Expand Down
2 changes: 1 addition & 1 deletion Eloquent/ModelNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ModelNotFoundException extends RuntimeException
public function setModel($model, $ids = [])
{
$this->model = $model;
$this->ids = is_array($ids) ? $ids : [$ids];
$this->ids = array_wrap($ids);

$this->message = "No query results for model [{$model}]";

Expand Down
8 changes: 2 additions & 6 deletions Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ public function groupBy(...$groups)
foreach ($groups as $group) {
$this->groups = array_merge(
(array) $this->groups,
is_array($group) ? $group : [$group]
array_wrap($group)
);
}

Expand Down Expand Up @@ -2019,11 +2019,7 @@ public function exists()
*/
public function count($columns = '*')
{
if (! is_array($columns)) {
$columns = [$columns];
}

return (int) $this->aggregate(__FUNCTION__, $columns);
return (int) $this->aggregate(__FUNCTION__, array_wrap($columns));
}

/**
Expand Down

0 comments on commit 58078b8

Please sign in to comment.