Skip to content

Apply fixes from StyleCI #1289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __call($method, $parameters)
// Convert the query parameters to a json string.
array_walk_recursive($parameters, function (&$item, $key) {
if ($item instanceof ObjectID) {
$item = (string)$item;
$item = (string) $item;
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/Jenssegers/Mongodb/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ public function raw($expression = null)
elseif ($results instanceof BSONDocument) {
$results = $results->getArrayCopy();

return $this->model->newFromBuilder((array)$results);
return $this->model->newFromBuilder((array) $results);
} // The result is a single object.
elseif (is_array($results) and array_key_exists('_id', $results)) {
return $this->model->newFromBuilder((array)$results);
return $this->model->newFromBuilder((array) $results);
}

return $results;
Expand Down
6 changes: 3 additions & 3 deletions src/Jenssegers/Mongodb/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getIdAttribute($value = null)

// Convert ObjectID to string.
if ($value instanceof ObjectID) {
return (string)$value;
return (string) $value;
}

return $value;
Expand Down Expand Up @@ -193,14 +193,14 @@ public function attributesToArray()
// nicely when your models are converted to JSON.
foreach ($attributes as $key => &$value) {
if ($value instanceof ObjectID) {
$value = (string)$value;
$value = (string) $value;
}
}

// Convert dot-notation dates.
foreach ($this->getDates() as $key) {
if (str_contains($key, '.') and array_has($attributes, $key)) {
array_set($attributes, $key, (string)$this->asDateTime(array_get($attributes, $key)));
array_set($attributes, $key, (string) $this->asDateTime(array_get($attributes, $key)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Helpers/QueriesRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function getHasCompareKey($relation)
protected function getConstrainedRelatedIds($relations, $operator, $count)
{
$relationCount = array_count_values(array_map(function ($id) {
return (string)$id; // Convert Back ObjectIds to Strings
return (string) $id; // Convert Back ObjectIds to Strings
}, is_array($relations) ? $relations : $relations->flatten()->toArray()));
// Remove unwanted related objects based on the operator and count.
$relationCount = array_filter($relationCount, function ($counted) use ($count, $operator) {
Expand Down
14 changes: 7 additions & 7 deletions src/Jenssegers/Mongodb/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ public function aggregate($function, $columns = [])
$this->bindings['select'] = $previousSelectBindings;

if (isset($results[0])) {
$result = (array)$results[0];
$result = (array) $results[0];

return $result['aggregate'];
}
Expand Down Expand Up @@ -537,7 +537,7 @@ public function insert(array $values)
// Batch insert
$result = $this->collection->insertMany($values);

return (1 == (int)$result->isAcknowledged());
return (1 == (int) $result->isAcknowledged());
}

/**
Expand All @@ -547,7 +547,7 @@ public function insertGetId(array $values, $sequence = null)
{
$result = $this->collection->insertOne($values);

if (1 == (int)$result->isAcknowledged()) {
if (1 == (int) $result->isAcknowledged()) {
if (is_null($sequence)) {
$sequence = '_id';
}
Expand Down Expand Up @@ -609,7 +609,7 @@ public function pluck($column, $key = null)
// Convert ObjectID's to strings
if ($key == '_id') {
$results = $results->map(function ($item) {
$item['_id'] = (string)$item['_id'];
$item['_id'] = (string) $item['_id'];
return $item;
});
}
Expand All @@ -632,7 +632,7 @@ public function delete($id = null)

$wheres = $this->compileWheres();
$result = $this->collection->DeleteMany($wheres);
if (1 == (int)$result->isAcknowledged()) {
if (1 == (int) $result->isAcknowledged()) {
return $result->getDeletedCount();
}

Expand All @@ -658,7 +658,7 @@ public function truncate()
{
$result = $this->collection->drop();

return (1 == (int)$result->ok);
return (1 == (int) $result->ok);
}

/**
Expand Down Expand Up @@ -789,7 +789,7 @@ protected function performUpdate($query, array $options = [])

$wheres = $this->compileWheres();
$result = $this->collection->UpdateMany($wheres, $query, $options);
if (1 == (int)$result->isAcknowledged()) {
if (1 == (int) $result->isAcknowledged()) {
return $result->getModifiedCount() ? $result->getModifiedCount() : $result->getUpsertedCount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function all()
$all = $this->getTable()->orderBy('_id', 'desc')->get()->all();

$all = array_map(function ($job) {
$job['id'] = (string)$job['_id'];
$job['id'] = (string) $job['_id'];
return $job;
}, $all);

Expand All @@ -50,7 +50,7 @@ public function find($id)
{
$job = $this->getTable()->find($id);

$job['id'] = (string)$job['_id'];
$job['id'] = (string) $job['_id'];

return $job;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Jenssegers/Mongodb/Relations/BelongsToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public function sync($ids, $detaching = true)
if ($detaching and count($detach) > 0) {
$this->detach($detach);

$changes['detached'] = (array)array_map(function ($v) {
return is_numeric($v) ? (int)$v : (string)$v;
$changes['detached'] = (array) array_map(function ($v) {
return is_numeric($v) ? (int) $v : (string) $v;
}, $detach);
}

Expand Down Expand Up @@ -192,14 +192,14 @@ public function attach($id, array $attributes = [], $touch = true)

$query = $this->newRelatedQuery();

$query->whereIn($this->related->getKeyName(), (array)$id);
$query->whereIn($this->related->getKeyName(), (array) $id);

// Attach the new parent id to the related model.
$query->push($this->foreignKey, $this->parent->getKey(), true);
}

// Attach the new ids to the parent model.
$this->parent->push($this->getRelatedKey(), (array)$id, true);
$this->parent->push($this->getRelatedKey(), (array) $id, true);

if ($touch) {
$this->touchIfTouching();
Expand All @@ -212,15 +212,15 @@ public function attach($id, array $attributes = [], $touch = true)
public function detach($ids = [], $touch = true)
{
if ($ids instanceof Model) {
$ids = (array)$ids->getKey();
$ids = (array) $ids->getKey();
}

$query = $this->newRelatedQuery();

// If associated IDs were passed to the method we will only delete those
// associations, otherwise all of the association ties will be broken.
// We'll return the numbers of affected rows when we do the deletes.
$ids = (array)$ids;
$ids = (array) $ids;

// Detach all ids from the parent model.
$this->parent->pull($this->getRelatedKey(), $ids);
Expand Down
4 changes: 2 additions & 2 deletions src/Jenssegers/Mongodb/Relations/EmbedsOneOrMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected function getEmbedded()
$attributes = $this->parent->getAttributes();

// Get embedded models form parent attributes.
$embedded = isset($attributes[$this->localKey]) ? (array)$attributes[$this->localKey] : null;
$embedded = isset($attributes[$this->localKey]) ? (array) $attributes[$this->localKey] : null;

return $embedded;
}
Expand Down Expand Up @@ -280,7 +280,7 @@ protected function toModel($attributes = [])
return;
}

$model = $this->related->newFromBuilder((array)$attributes);
$model = $this->related->newFromBuilder((array) $attributes);

$model->setParentRelation($this);

Expand Down