Skip to content
This repository has been archived by the owner on Feb 16, 2022. It is now read-only.

Apply fixes from StyleCI #178

Merged
merged 1 commit into from Jul 18, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Repositories/BaseRepository.php
Expand Up @@ -189,35 +189,35 @@ protected function prepareQuery($model)

// Add a basic where clause to the query
foreach ($this->where as $where) {
list($attribute, $operator, $value, $boolean) = array_pad($where, 4, null);
[$attribute, $operator, $value, $boolean] = array_pad($where, 4, null);

$model = $model->where($attribute, $operator, $value, $boolean);
}

// Add a "where in" clause to the query
foreach ($this->whereIn as $whereIn) {
list($attribute, $values, $boolean, $not) = array_pad($whereIn, 4, null);
[$attribute, $values, $boolean, $not] = array_pad($whereIn, 4, null);

$model = $model->whereIn($attribute, $values, $boolean, $not);
}

// Add a "where not in" clause to the query
foreach ($this->whereNotIn as $whereNotIn) {
list($attribute, $values, $boolean) = array_pad($whereNotIn, 3, null);
[$attribute, $values, $boolean] = array_pad($whereNotIn, 3, null);

$model = $model->whereNotIn($attribute, $values, $boolean);
}

// Add a "where has" clause to the query
foreach ($this->whereHas as $whereHas) {
list($relation, $callback, $operator, $count) = array_pad($whereHas, 4, null);
[$relation, $callback, $operator, $count] = array_pad($whereHas, 4, null);

$model = $model->whereHas($relation, $callback, $operator, $count);
}

// Add a "scope" to the query
foreach ($this->scopes as $scope => $parameters) {
$model = $model->$scope(...$parameters);
$model = $model->{$scope}(...$parameters);
}

// Set the "offset" value of the query
Expand All @@ -232,7 +232,7 @@ protected function prepareQuery($model)

// Add an "order by" clause to the query.
foreach ($this->orderBy as $orderBy) {
list($attribute, $direction) = $orderBy;
[$attribute, $direction] = $orderBy;

$model = $model->orderBy($attribute, $direction);
}
Expand All @@ -246,7 +246,7 @@ protected function prepareQuery($model)

// Add a "having" clause to the query
foreach ($this->having as $having) {
list($column, $operator, $value, $boolean) = array_pad($having, 4, null);
[$column, $operator, $value, $boolean] = array_pad($having, 4, null);

$model = $model->having($column, $operator, $value, $boolean);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Repositories/EloquentRepository.php
Expand Up @@ -136,7 +136,7 @@ public function simplePaginate($perPage = null, $attributes = ['*'], $pageName =
public function findWhere(array $where, $attributes = ['*'])
{
return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($where, $attributes) {
list($attribute, $operator, $value, $boolean) = array_pad($where, 4, null);
[$attribute, $operator, $value, $boolean] = array_pad($where, 4, null);

$this->where($attribute, $operator, $value, $boolean);

Expand All @@ -150,7 +150,7 @@ public function findWhere(array $where, $attributes = ['*'])
public function findWhereIn(array $where, $attributes = ['*'])
{
return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($where, $attributes) {
list($attribute, $values, $boolean, $not) = array_pad($where, 4, null);
[$attribute, $values, $boolean, $not] = array_pad($where, 4, null);

$this->whereIn($attribute, $values, $boolean, $not);

Expand All @@ -164,7 +164,7 @@ public function findWhereIn(array $where, $attributes = ['*'])
public function findWhereNotIn(array $where, $attributes = ['*'])
{
return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($where, $attributes) {
list($attribute, $values, $boolean) = array_pad($where, 3, null);
[$attribute, $values, $boolean] = array_pad($where, 3, null);

$this->whereNotIn($attribute, $values, $boolean);

Expand All @@ -178,7 +178,7 @@ public function findWhereNotIn(array $where, $attributes = ['*'])
public function findWhereHas(array $where, $attributes = ['*'])
{
return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($where, $attributes) {
list($relation, $callback, $operator, $count) = array_pad($where, 4, null);
[$relation, $callback, $operator, $count] = array_pad($where, 4, null);

$this->whereHas($relation, $callback, $operator, $count);

Expand Down Expand Up @@ -403,7 +403,7 @@ protected function extractRelations($entity, array $attributes): array
if (method_exists($entity, $relation)) {
$relations[$relation] = [
'values' => $attributes[$relation],
'class' => get_class($entity->$relation()),
'class' => get_class($entity->{$relation}()),
];
}
});
Expand All @@ -426,7 +426,7 @@ protected function syncRelations($entity, array $relations, $detaching = true):
switch ($relation['class']) {
case 'Illuminate\Database\Eloquent\Relations\BelongsToMany':
default:
$entity->$method()->sync((array) $relation['values'], $detaching);
$entity->{$method}()->sync((array) $relation['values'], $detaching);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Criteriable.php
Expand Up @@ -156,7 +156,7 @@ protected function addCriterion($criterion, $list)
$criterion = call_user_func_array([$this, 'instantiateCriterion'], $this->extractCriterionClassAndArgs($criterion));
}

$this->$list[$this->getCriterionName($criterion)] = $criterion;
$this->{$list}[$this->getCriterionName($criterion)] = $criterion;

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/AbstractEloquentTest.php
Expand Up @@ -22,7 +22,7 @@ abstract class AbstractEloquentTests extends TestCase
protected $container;

/** Setup the database schema. */
public function setUp()
protected function setUp()
{
$this->setupContainer();
$this->setupDatabase(new Manager($this->getContainer()));
Expand Down Expand Up @@ -128,7 +128,7 @@ protected function schema(): Builder
*
* @return void
*/
public function tearDown(): void
protected function tearDown(): void
{
$this->schema()->drop('users');
$this->schema()->drop('posts');
Expand Down
1 change: 1 addition & 0 deletions tests/EloquentRepositoryCriteriaTest.php
Expand Up @@ -495,6 +495,7 @@ public function apply($builder, $repository)
class ThirdTestWithArgumentsCriterion implements \Rinvex\Repository\Contracts\CriterionContract
{
protected $from;

protected $to;

public function __construct($from, $to)
Expand Down
1 change: 1 addition & 0 deletions tests/Stubs/EloquentPost.php
Expand Up @@ -7,6 +7,7 @@
class EloquentPost extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'posts';

protected $fillable = ['user_id', 'parent_id', 'name'];

public function user()
Expand Down
1 change: 1 addition & 0 deletions tests/Stubs/EloquentPostRepository.php
Expand Up @@ -9,5 +9,6 @@
class EloquentPostRepository extends EloquentRepository
{
protected $model = EloquentPost::class;

protected $repositoryId = 'rinvex.repository.post';
}
1 change: 1 addition & 0 deletions tests/Stubs/EloquentUser.php
Expand Up @@ -7,6 +7,7 @@
class EloquentUser extends \Illuminate\Database\Eloquent\Model
{
protected $table = 'users';

protected $fillable = ['name', 'email', 'age'];

public function posts()
Expand Down
1 change: 1 addition & 0 deletions tests/Stubs/EloquentUserRepository.php
Expand Up @@ -12,5 +12,6 @@ class EloquentUserRepository extends EloquentRepository
use Criteriable;

protected $model = EloquentUser::class;

protected $repositoryId = 'rinvex.repository.user';
}