Skip to content

[4.x] Apply fixes from StyleCI #1986

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
Mar 5, 2020
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
6 changes: 3 additions & 3 deletions src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class DatabaseTokenRepository extends BaseDatabaseTokenRepository
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getPayload($email, $token)
{
Expand All @@ -23,7 +23,7 @@ protected function getPayload($email, $token)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function tokenExpired($createdAt)
{
Expand All @@ -33,7 +33,7 @@ protected function tokenExpired($createdAt)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function tokenRecentlyCreated($createdAt)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Auth/PasswordBrokerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class PasswordBrokerManager extends BasePasswordBrokerManager
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function createTokenRepository(array $config)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function registerTokenRepository()
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function registerPasswordBroker()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Jenssegers/Mongodb/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __call($method, $parameters)
}
}

$queryString = $this->collection->getCollectionName() . '.' . $method . '(' . implode(',', $query) . ')';
$queryString = $this->collection->getCollectionName().'.'.$method.'('.implode(',', $query).')';

$this->connection->logQuery($queryString, [], $time);
}
Expand Down
33 changes: 17 additions & 16 deletions src/Jenssegers/Mongodb/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function getCollection($name)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getSchemaBuilder()
{
Expand Down Expand Up @@ -119,7 +119,7 @@ public function getDatabaseName()
}

/**
* Get the name of the default database based on db config or try to detect it from dsn
* Get the name of the default database based on db config or try to detect it from dsn.
* @param string $dsn
* @param array $config
* @return string
Expand All @@ -131,7 +131,7 @@ protected function getDefaultDatabaseName($dsn, $config)
if (preg_match('/^mongodb(?:[+]srv)?:\\/\\/.+\\/([^?&]+)/s', $dsn, $matches)) {
$config['database'] = $matches[1];
} else {
throw new InvalidArgumentException("Database is not properly configured.");
throw new InvalidArgumentException('Database is not properly configured.');
}
}

Expand All @@ -155,18 +155,18 @@ protected function createConnection($dsn, array $config, array $options)
}

// Check if the credentials are not already set in the options
if (!isset($options['username']) && !empty($config['username'])) {
if (! isset($options['username']) && ! empty($config['username'])) {
$options['username'] = $config['username'];
}
if (!isset($options['password']) && !empty($config['password'])) {
if (! isset($options['password']) && ! empty($config['password'])) {
$options['password'] = $config['password'];
}

return new Client($dsn, $options, $driverOptions);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function disconnect()
{
Expand All @@ -180,7 +180,7 @@ public function disconnect()
*/
protected function hasDsnString(array $config)
{
return isset($config['dsn']) && !empty($config['dsn']);
return isset($config['dsn']) && ! empty($config['dsn']);
}

/**
Expand All @@ -205,14 +205,15 @@ protected function getHostDsn(array $config)

foreach ($hosts as &$host) {
// Check if we need to add a port to the host
if (strpos($host, ':') === false && !empty($config['port'])) {
$host = $host . ':' . $config['port'];
if (strpos($host, ':') === false && ! empty($config['port'])) {
$host = $host.':'.$config['port'];
}
}

// Check if we want to authenticate against a specific database.
$auth_database = isset($config['options']) && !empty($config['options']['database']) ? $config['options']['database'] : null;
return 'mongodb://' . implode(',', $hosts) . ($auth_database ? '/' . $auth_database : '');
$auth_database = isset($config['options']) && ! empty($config['options']['database']) ? $config['options']['database'] : null;

return 'mongodb://'.implode(',', $hosts).($auth_database ? '/'.$auth_database : '');
}

/**
Expand All @@ -228,39 +229,39 @@ protected function getDsn(array $config)
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getElapsedTime($start)
{
return parent::getElapsedTime($start);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function getDriverName()
{
return 'mongodb';
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getDefaultPostProcessor()
{
return new Query\Processor();
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getDefaultQueryGrammar()
{
return new Query\Grammar();
}

/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getDefaultSchemaGrammar()
{
Expand Down
20 changes: 10 additions & 10 deletions src/Jenssegers/Mongodb/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,63 @@ class Builder extends EloquentBuilder
];

/**
* @inheritdoc
* {@inheritdoc}
*/
public function update(array $values, array $options = [])
{
return $this->toBase()->update($this->addUpdatedAtColumn($values), $options);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function insert(array $values)
{
return parent::insert($values);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function insertGetId(array $values, $sequence = null)
{
return parent::insertGetId($values, $sequence);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function delete()
{
return parent::delete();
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function increment($column, $amount = 1, array $extra = [])
{
return parent::increment($column, $amount, $extra);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function decrement($column, $amount = 1, array $extra = [])
{
return parent::decrement($column, $amount, $extra);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function chunkById($count, callable $callback, $column = '_id', $alias = null)
{
return parent::chunkById($count, $callback, $column, $alias);
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function raw($expression = null)
{
Expand Down Expand Up @@ -116,13 +116,13 @@ public function raw($expression = null)
* Add the "updated at" column to an array of values.
* TODO Remove if https://github.com/laravel/framework/commit/6484744326531829341e1ff886cc9b628b20d73e
* wiil be reverted
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791
* Issue in laravel frawework https://github.com/laravel/framework/issues/27791.
* @param array $values
* @return array
*/
protected function addUpdatedAtColumn(array $values)
{
if (!$this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
if (! $this->model->usesTimestamps() || $this->model->getUpdatedAtColumn() === null) {
return $values;
}

Expand Down
32 changes: 16 additions & 16 deletions src/Jenssegers/Mongodb/Eloquent/HybridRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use Jenssegers\Mongodb\Relations\BelongsToMany;
use Jenssegers\Mongodb\Relations\HasMany;
use Jenssegers\Mongodb\Relations\HasOne;
use Jenssegers\Mongodb\Relations\MorphTo;
use Jenssegers\Mongodb\Relations\MorphMany;
use Jenssegers\Mongodb\Relations\MorphTo;

trait HybridRelations
{
Expand All @@ -24,7 +24,7 @@ trait HybridRelations
public function hasOne($related, $foreignKey = null, $localKey = null)
{
// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::hasOne($related, $foreignKey, $localKey);
}

Expand All @@ -49,13 +49,13 @@ public function hasOne($related, $foreignKey = null, $localKey = null)
public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
{
// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::morphOne($related, $name, $type, $id, $localKey);
}

$instance = new $related;

list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);

$localKey = $localKey ?: $this->getKeyName();

Expand All @@ -72,7 +72,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
public function hasMany($related, $foreignKey = null, $localKey = null)
{
// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::hasMany($related, $foreignKey, $localKey);
}

Expand All @@ -97,7 +97,7 @@ public function hasMany($related, $foreignKey = null, $localKey = null)
public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
{
// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::morphMany($related, $name, $type, $id, $localKey);
}

Expand All @@ -106,7 +106,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
// Here we will gather up the morph type and ID for the relationship so that we
// can properly query the intermediate table of a relation. Finally, we will
// get the table and create the relationship instances for the developers.
list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);

$table = $instance->getTable();

Expand All @@ -129,21 +129,21 @@ public function belongsTo($related, $foreignKey = null, $otherKey = null, $relat
// the calling method's name and use that as the relationship name as most
// of the time this will be what we desire to use for the relationships.
if ($relation === null) {
list($current, $caller) = debug_backtrace(false, 2);
[$current, $caller] = debug_backtrace(false, 2);

$relation = $caller['function'];
}

// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::belongsTo($related, $foreignKey, $otherKey, $relation);
}

// If no foreign key was supplied, we can use a backtrace to guess the proper
// foreign key name by using the name of the relationship function, which
// when combined with an "_id" should conventionally match the columns.
if ($foreignKey === null) {
$foreignKey = Str::snake($relation) . '_id';
$foreignKey = Str::snake($relation).'_id';
}

$instance = new $related;
Expand Down Expand Up @@ -172,12 +172,12 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
// since that is most likely the name of the polymorphic interface. We can
// use that to get both the class and foreign key that will be utilized.
if ($name === null) {
list($current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
[$current, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);

$name = Str::snake($caller['function']);
}

list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);

// If the type value is null it is probably safe to assume we're eager loading
// the relationship. When that is the case we will pass in a dummy query as
Expand Down Expand Up @@ -230,7 +230,7 @@ public function belongsToMany(
}

// Check if it is a relation with an original model.
if (!is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
if (! is_subclass_of($related, \Jenssegers\Mongodb\Eloquent\Model::class)) {
return parent::belongsToMany(
$related,
$collection,
Expand All @@ -245,11 +245,11 @@ public function belongsToMany(
// First, we'll need to determine the foreign key and "other key" for the
// relationship. Once we have determined the keys we'll make the query
// instances as well as the relationship instances we need for this.
$foreignKey = $foreignKey ?: $this->getForeignKey() . 's';
$foreignKey = $foreignKey ?: $this->getForeignKey().'s';

$instance = new $related;

$otherKey = $otherKey ?: $instance->getForeignKey() . 's';
$otherKey = $otherKey ?: $instance->getForeignKey().'s';

// If no table name was provided, we can guess it by concatenating the two
// models using underscores in alphabetical order. The two model names
Expand Down Expand Up @@ -289,7 +289,7 @@ protected function guessBelongsToManyRelation()
}

/**
* @inheritdoc
* {@inheritdoc}
*/
public function newEloquentBuilder($query)
{
Expand Down
Loading