From ef76d72b56eccccfd8d029c0b1aa53388d3ed3b2 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 19 Sep 2014 20:25:59 -0700 Subject: [PATCH] Added ability to get all saved variables. --- VERSION | 2 +- flight/Engine.php | 4 +++- tests/FlightTest.php | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index c813fe1..3c43790 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.5 +1.2.6 diff --git a/flight/Engine.php b/flight/Engine.php index b26de60..ce82d41 100644 --- a/flight/Engine.php +++ b/flight/Engine.php @@ -213,7 +213,9 @@ class Engine { * @param string $key Key * @return mixed */ - public function get($key) { + public function get($key = null) { + if ($key === null) return $this->vars; + return isset($this->vars[$key]) ? $this->vars[$key] : null; } diff --git a/tests/FlightTest.php b/tests/FlightTest.php index 70ed453..570bf41 100644 --- a/tests/FlightTest.php +++ b/tests/FlightTest.php @@ -34,6 +34,19 @@ class FlightTest extends PHPUnit_Framework_TestCase $var = Flight::get('a'); $this->assertEquals(1, $var); + + Flight::clear(); + $vars = Flight::get(); + + $this->assertEquals(0, count($vars)); + + Flight::set('a', 1); + Flight::set('b', 2); + $vars = Flight::get(); + + $this->assertEquals(2, count($vars)); + $this->assertEquals(1, $vars['a']); + $this->assertEquals(2, $vars['b']); } // Register a class