Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Sep 13, 2023
1 parent 4836069 commit db9dd10
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 44 deletions.
21 changes: 5 additions & 16 deletions src/OptimusManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,13 @@ class OptimusManager extends AbstractManager
{
/**
* The factory instance.
*
* @var \Cog\Laravel\Optimus\OptimusFactory
*/
private $factory;
private OptimusFactory $factory;

/**
* Create a new Optimus manager instance.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Cog\Laravel\Optimus\OptimusFactory $factory
* @return void
*/
public function __construct(Repository $config, OptimusFactory $factory)
{
public function __construct(
Repository $config,
OptimusFactory $factory
) {
parent::__construct($config);

$this->factory = $factory;
Expand All @@ -53,8 +46,6 @@ protected function createConnection(array $config): Optimus

/**
* Get the configuration name.
*
* @return string
*/
protected function getConfigName(): string
{
Expand All @@ -63,8 +54,6 @@ protected function getConfigName(): string

/**
* Get the factory instance.
*
* @return \Cog\Laravel\Optimus\OptimusFactory
*/
public function getFactory(): OptimusFactory
{
Expand Down
26 changes: 6 additions & 20 deletions src/Providers/OptimusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ class OptimusServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
public function boot(): void
{
$this->setupConfig();
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
public function register(): void
{
$this->bindFactory();
$this->bindManager();
Expand All @@ -47,8 +43,6 @@ public function register()

/**
* Get the services provided by the provider.
*
* @return string[]
*/
public function provides(): array
{
Expand All @@ -61,10 +55,8 @@ public function provides(): array

/**
* Setup the config.
*
* @return void
*/
protected function setupConfig()
protected function setupConfig(): void
{
$source = realpath(__DIR__ . '/../../config/optimus.php');

Expand All @@ -79,10 +71,8 @@ protected function setupConfig()

/**
* Register the factory class.
*
* @return void
*/
protected function bindFactory()
protected function bindFactory(): void
{
$this->app->singleton('optimus.factory', function () {
return new OptimusFactory();
Expand All @@ -93,10 +83,8 @@ protected function bindFactory()

/**
* Register the manager class.
*
* @return void
*/
protected function bindManager()
protected function bindManager(): void
{
$this->app->singleton('optimus', function (Container $app) {
$config = $app['config'];
Expand All @@ -110,10 +98,8 @@ protected function bindManager()

/**
* Register the bindings.
*
* @return void
*/
protected function bindOptimus()
protected function bindOptimus(): void
{
$this->app->bind('optimus.connection', function (Container $app) {
$manager = $app['optimus'];
Expand Down
2 changes: 1 addition & 1 deletion tests/OptimusFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public function testMakeStandard(): void

protected function getOptimusFactory(): OptimusFactory
{
return new OptimusFactory;
return new OptimusFactory();
}
}
11 changes: 10 additions & 1 deletion tests/Stubs/Models/UserWithCustomOptimusConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of Laravel Optimus.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Cog\Tests\Laravel\Optimus\Stubs\Models;

use Cog\Laravel\Optimus\Traits\OptimusEncodedRouteKey;
Expand All @@ -11,7 +20,7 @@ final class UserWithCustomOptimusConnection extends Model
{
use OptimusEncodedRouteKey;

protected $optimusConnection = 'custom';
protected string $optimusConnection = 'custom';

protected $table = 'users';

Expand Down
9 changes: 9 additions & 0 deletions tests/Stubs/Models/UserWithDefaultOptimusConnection.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of Laravel Optimus.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Cog\Tests\Laravel\Optimus\Stubs\Models;

use Cog\Laravel\Optimus\Traits\OptimusEncodedRouteKey;
Expand Down
6 changes: 0 additions & 6 deletions tests/Traits/OptimusEncodedRouteKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ public function testExistingIntegerValuesBelow256AreResolved()

/**
* Create a test user with default Optimus connection in the database.
*
* @return \Cog\Tests\Laravel\Optimus\Stubs\Models\UserWithDefaultOptimusConnection
*/
protected function createUserWithDefaultOptimusConnection(array $attributes = []): UserWithDefaultOptimusConnection
{
Expand All @@ -196,8 +194,6 @@ protected function createUserWithDefaultOptimusConnection(array $attributes = []

/**
* Create a test user with custom Optimus connection in the database.
*
* @return \Cog\Tests\Laravel\Optimus\Stubs\Models\UserWithCustomOptimusConnection
*/
protected function createUserWithCustomOptimusConnection(): UserWithCustomOptimusConnection
{
Expand All @@ -210,8 +206,6 @@ protected function createUserWithCustomOptimusConnection(): UserWithCustomOptimu

/**
* Configure some random prime numbers.
*
* @return void
*/
protected function configurePrimeNumbers(): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of Laravel Optimus.
*
* (c) Anton Komarev <anton@komarev.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

use Illuminate\Database\Migrations\Migration;
Expand Down

0 comments on commit db9dd10

Please sign in to comment.