Skip to content

Commit

Permalink
Reformat code & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuell1 committed Aug 13, 2023
1 parent 509364c commit cd2ed50
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 190 deletions.
4 changes: 2 additions & 2 deletions src/Translation/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php namespace October\Rain\Translation;

use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;

/**
* TranslationServiceProvider is a custom translator implemenation based on Laravel
*
*
* @package october\translation
* @author Alexey Bobkov, Samuel Georges
*/
Expand Down
21 changes: 10 additions & 11 deletions src/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function set($key, $value = null, $locale = null)
foreach ($key as $innerKey => $innerValue) {
$this->set($innerKey, $innerValue, $locale);
}
}
else {
} else {
$locale = $locale ?: $this->locale;

$this->loaded['*']['*'][$locale][$key] = $value;
Expand All @@ -59,7 +58,7 @@ protected function getValidationSpecific($key, $replace, $locale)
!str_starts_with($key, 'validation.custom.') &&
!str_starts_with($key, 'validation.attributes.')
) {
$nativeKey = 'system::'.$key;
$nativeKey = 'system::' . $key;
$line = $this->get($nativeKey, $replace, $locale);
if ($line !== $nativeKey) {
return $line;
Expand All @@ -72,9 +71,9 @@ protected function getValidationSpecific($key, $replace, $locale)
/**
* trans returns the translation for a given key
*
* @param array|string $id
* @param array $parameters
* @param string $locale
* @param array|string $id
* @param array $parameters
* @param string $locale
* @return string
*/
public function trans($id, array $parameters = [], $locale = null)
Expand All @@ -85,10 +84,10 @@ public function trans($id, array $parameters = [], $locale = null)
/**
* transChoice gets a translation according to an integer value
*
* @param string $id
* @param int $number
* @param array $parameters
* @param string $locale
* @param string $id
* @param int $number
* @param array $parameters
* @param string $locale
* @return string
*/
public function transChoice($id, $number, array $parameters = [], $locale = null)
Expand All @@ -99,7 +98,7 @@ public function transChoice($id, $number, array $parameters = [], $locale = null
/**
* localeArray gets the array of locales to be checked
*
* @param string|null $locale
* @param string|null $locale
* @return array
*/
protected function localeArray($locale)
Expand Down
24 changes: 12 additions & 12 deletions tests/Assetic/StylesheetMinifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StylesheetMinifyTest extends TestCase
{
public function testSpaceRemoval()
{
$input = 'body{width: calc(99.9% * 1/1 - 0px); height: 0px;}';
$input = 'body{width: calc(99.9% * 1/1 - 0px); height: 0px;}';
$output = 'body{width:calc(99.9% * 1/1 - 0px);height:0px}';

$mockAsset = new MockAsset($input);
Expand All @@ -20,8 +20,8 @@ public function testSpaceRemoval()

public function testEmptyClassPreserve()
{
$input = ''.
'.view { /*
$input = '' .
'.view { /*
* Text
*/
/*
Expand All @@ -48,8 +48,8 @@ public function testEmptyClassPreserve()

public function testEmptyCommentPreserve()
{
$input = ''.
'
$input = '' .
'
body { background: blue; }
/**/
.view { color: red; }';
Expand All @@ -65,7 +65,7 @@ public function testEmptyCommentPreserve()

public function testSpecialCommentPreservation()
{
$input = 'body {/*! Keep me */}';
$input = 'body {/*! Keep me */}';
$output = 'body{/*! Keep me */}';

$mockAsset = new MockAsset($input);
Expand All @@ -77,7 +77,7 @@ public function testSpecialCommentPreservation()

public function testCommentRemoval()
{
$input = 'body{/* First comment */} /* Second comment */';
$input = 'body{/* First comment */} /* Second comment */';
$output = 'body{}';

$mockAsset = new MockAsset($input);
Expand All @@ -89,7 +89,7 @@ public function testCommentRemoval()

public function testCommentPreservationInVar()
{
$input = '--ring-inset: var(--empty, /*!*/ /*!*/);';
$input = '--ring-inset: var(--empty, /*!*/ /*!*/);';
$output = '--ring-inset:var(--empty,/*!*/ /*!*/);';

$mockAsset = new MockAsset($input);
Expand All @@ -101,7 +101,7 @@ public function testCommentPreservationInVar()

public function testMinifyPreservationInVar()
{
$input = ''.
$input = '' .
'select:focus {
--ring-inset: var(--empty, /*!*/ /*!*/);
--ring-offset-width: 0px;
Expand All @@ -119,7 +119,7 @@ public function testMinifyPreservationInVar()

public function testUnitPreservationInVar()
{
$input = '--offset-width: 0px';
$input = '--offset-width: 0px';
$output = '--offset-width:0px';

$mockAsset = new MockAsset($input);
Expand All @@ -131,7 +131,7 @@ public function testUnitPreservationInVar()

public function testAttributeSelectorsWithLess()
{
$input = ''.
$input = '' .
'[class^="icon-"]:before,
[class*=" icon-"]:before {
speak: none;
Expand All @@ -152,7 +152,7 @@ public function testAttributeSelectorsWithLess()

public function testSourceMappingUrlWithSpecialComment()
{
$input = ''.
$input = '' .
'/*! keep me */*,:after,:before { opacity: 1; }body {background: purple;}
/*# sourceMappingUrl*/';
Expand Down
14 changes: 7 additions & 7 deletions tests/Benchmark/Router/RouterBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ public function init()
// Build padded routes
$routes = [];
foreach ($this->fixtures as $index => $rule) {
$routes['pad1'.$index] = '/pad1/'.$rule;
$routes['pad2'.$index] = '/pad2/'.$rule;
$routes['pad3'.$index] = '/pad3/'.$rule;
$routes['pad3'.$index] = '/pad4/'.$rule;
$routes['pad3'.$index] = '/pad5/'.$rule;
$routes['pad1' . $index] = '/pad1/' . $rule;
$routes['pad2' . $index] = '/pad2/' . $rule;
$routes['pad3' . $index] = '/pad3/' . $rule;
$routes['pad3' . $index] = '/pad4/' . $rule;
$routes['pad3' . $index] = '/pad5/' . $rule;
}

// Final target at end (120 routes)
foreach ($this->fixtures as $index => $rule) {
$routes['rule'.$index] = $rule;
$routes['rule' . $index] = $rule;
}

// Register with router
Expand All @@ -94,7 +94,7 @@ public function benchRoute()
$router = new Router;

foreach ($this->routes as $index => $rule) {
$router->route('rule'.$index, $rule);
$router->route('rule' . $index, $rule);
}

$router->match('authors/test/details');
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/SortableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public function setUp(): void
{
$capsule = new Illuminate\Database\Capsule\Manager;
$capsule->addConnection([
'driver' => 'sqlite',
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => ''
'prefix' => ''
]);
$capsule->setAsGlobal();
$capsule->bootEloquent();
Expand Down
8 changes: 6 additions & 2 deletions tests/Database/Traits/SluggableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ public function setUp(): void
});

// Mock app instance for this test
App::swap(new class {
public function getLocale() { return 'en'; }
App::swap(new class
{
public function getLocale()
{
return 'en';
}
});
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Database/UpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UpdaterTest extends TestCase
{
public function setUp(): void
{
include_once __DIR__.'/../fixtures/database/SampleClass.php';
include_once __DIR__ . '/../fixtures/database/SampleClass.php';

$this->updater = new Updater();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Events/EventDispatcherTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use October\Rain\Events\Dispatcher;
use October\Rain\Events\PriorityDispatcher;
use October\Rain\Events\FakeDispatcher;
use October\Rain\Events\PriorityDispatcher;

/**
* EventDispatcherTest
Expand Down
8 changes: 7 additions & 1 deletion tests/Extension/ExtendableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testDynamicPropertyOnClass()

public function testDynamicallyImplementingClass()
{
ExtendableTestExampleImplementableClass::extend(function($obj) {
ExtendableTestExampleImplementableClass::extend(function ($obj) {
$obj->implementClassWith('ExtendableTestExampleBehaviorClass2');
$obj->implementClassWith('ExtendableTestExampleBehaviorClass2');
$obj->implementClassWith('ExtendableTestExampleBehaviorClass2');
Expand Down Expand Up @@ -296,6 +296,7 @@ public function getFoo()
/*
* Example class that has an invalid implementation
*/

class ExtendableTestInvalidExtendableClass extends Extendable
{
public $implement = 24;
Expand All @@ -306,6 +307,7 @@ class ExtendableTestInvalidExtendableClass extends Extendable
/*
* Example class that has extensions enabled
*/

class ExtendableTestExampleExtendableClass extends Extendable
{
public $implement = ['ExtendableTestExampleBehaviorClass1'];
Expand Down Expand Up @@ -357,6 +359,7 @@ public static function getName()
/*
* Example class with soft implement failure
*/

class ExtendableTestExampleExtendableSoftImplementFakeClass extends Extendable
{
public $implement = ['@RabbleRabbleRabble'];
Expand All @@ -370,6 +373,7 @@ public static function getStatus()
/*
* Example class with soft implement success
*/

class ExtendableTestExampleExtendableSoftImplementRealClass extends Extendable
{
public $implement = ['@ExtendableTestExampleBehaviorClass1'];
Expand All @@ -378,6 +382,7 @@ class ExtendableTestExampleExtendableSoftImplementRealClass extends Extendable
/*
* Example class with soft implement hybrid
*/

class ExtendableTestExampleExtendableSoftImplementComboClass extends Extendable
{
public $implement = [
Expand All @@ -390,6 +395,7 @@ class ExtendableTestExampleExtendableSoftImplementComboClass extends Extendable
/*
* Example class that has extensions enabled using dot notation
*/

class ExtendableTestExampleExtendableClassDotNotation extends Extendable
{
public $implement = ['ExtendableTest.ExampleBehaviorClass1'];
Expand Down
1 change: 1 addition & 0 deletions tests/Extension/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function testExtendingBehavior()
/*
* Example class that has extensions enabled
*/

class ExtensionTestExampleExtendableClass extends Extendable
{
public $implement = ['ExtensionTestExampleBehaviorClass1'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Halcyon/DatasourceResolverTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use October\Rain\Filesystem\Filesystem;
use October\Rain\Halcyon\Datasource\Resolver;
use October\Rain\Halcyon\Datasource\FileDatasource;
use October\Rain\Halcyon\Datasource\Resolver;

class DatasourceResolverTest extends TestCase
{
Expand Down
Loading

0 comments on commit cd2ed50

Please sign in to comment.