From 11fa98c0a964749bb40ac137800b6649a2358018 Mon Sep 17 00:00:00 2001 From: Bryan Horna Date: Tue, 26 May 2020 21:02:48 -0500 Subject: [PATCH] Apply Prettier codestyle to everything --- readme.md | 28 +++++++++++++++------------- tests/HelperTest.php | 30 ++++++++++++++++++------------ 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/readme.md b/readme.md index 339b3d4..5efa803 100644 --- a/readme.md +++ b/readme.md @@ -28,11 +28,13 @@ composer require bryanjhv/slim-session:~4.0 ```php $app = \Slim\Factory\AppFactory::create(); -$app->add(new \Slim\Middleware\Session([ - 'name' => 'dummy_session', - 'autorefresh' => true, - 'lifetime' => '1 hour' -])); +$app->add( + new \Slim\Middleware\Session([ + 'name' => 'dummy_session', + 'autorefresh' => true, + 'lifetime' => '1 hour', + ]) +); ``` ### Supported options @@ -52,10 +54,10 @@ $app->add(new \Slim\Middleware\Session([ serious performance leaks (see #30): ```php [ - 'session.gc_divisor' => 1, - 'session.gc_probability' => 1, - 'session.gc_maxlifetime' => 30 * 24 * 60 * 60, - ] + 'session.gc_divisor' => 1, + 'session.gc_probability' => 1, + 'session.gc_maxlifetime' => 30 * 24 * 60 * 60, + ]; ``` ## Session helper @@ -63,11 +65,11 @@ $app->add(new \Slim\Middleware\Session([ A `Helper` class is available, which you can register globally or instantiate: ```php -$container = new \DI\Container; +$container = new \DI\Container(); // Register globally to app $container->set('session', function () { - return new \SlimSession\Helper; + return new \SlimSession\Helper(); }); \Slim\Factory\AppFactory::setContainer($container); ``` @@ -77,7 +79,7 @@ That will provide `$app->get('session')`, so you can do: ```php $app->get('/', function ($req, $res) { // or $this->get('session') if registered - $session = new \SlimSession\Helper; + $session = new \SlimSession\Helper(); // Check if variable exists $exists = $session->exists('my_key'); @@ -97,7 +99,7 @@ $app->get('/', function ($req, $res) { // Merge value recursively $app->get('session')->merge('my_key', ['first' => 'value']); $session->merge('my_key', ['second' => ['a' => 'A']]); - $letter_a = $session['my_key']['second']['a']; // "A" + $letter_a = $session['my_key']['second']['a']; // "A" // Delete variable $session->delete('my_key'); diff --git a/tests/HelperTest.php b/tests/HelperTest.php index 977310f..52f3255 100644 --- a/tests/HelperTest.php +++ b/tests/HelperTest.php @@ -14,7 +14,7 @@ protected function setUp() public function testExists() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = $data = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -30,7 +30,7 @@ public function testExists() public function testSet() { - $helper = new Helper; + $helper = new Helper(); $helper->set('a', 'A'); $this->assertSame(['a' => 'A'], $_SESSION); @@ -44,22 +44,28 @@ public function testSet() public function testMerge() { - $helper = new Helper; + $helper = new Helper(); $helper->set('a', []); $helper->merge('a', ['a' => 'A']); $this->assertSame(['a' => ['a' => 'A']], $_SESSION); $helper->merge('a', ['b' => ['a' => 'A']]); - $this->assertSame(['a' => ['a' => 'A', 'b' => ['a' => 'A']]], $_SESSION); + $this->assertSame( + ['a' => ['a' => 'A', 'b' => ['a' => 'A']]], + $_SESSION + ); $helper->merge('a', ['b' => ['b' => 'B']]); - $this->assertSame(['a' => ['a' => 'A', 'b' => ['a' => 'A', 'b' => 'B']]], $_SESSION); + $this->assertSame( + ['a' => ['a' => 'A', 'b' => ['a' => 'A', 'b' => 'B']]], + $_SESSION + ); } public function testGet() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -76,7 +82,7 @@ public function testGet() public function testDelete() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = $data = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -96,7 +102,7 @@ public function testDelete() public function testClear() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -109,7 +115,7 @@ public function testClear() */ public function testId() { - $helper = new Helper; + $helper = new Helper(); $this->assertSame(session_id(), $helper::id()); $this->assertNotSame(session_id(), $sessionId = $helper::id(true)); @@ -121,7 +127,7 @@ public function testId() */ public function testDestroy() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -140,7 +146,7 @@ public function testDestroy() public function testCount() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = ['a' => 'A', 'b' => 'B', 'c' => 'C']; @@ -149,7 +155,7 @@ public function testCount() public function testIterator() { - $helper = new Helper; + $helper = new Helper(); $_SESSION = ['a' => 'A', 'b' => 'B', 'c' => 'C'];