diff --git a/src/Parse/ParseConfig.php b/src/Parse/ParseConfig.php new file mode 100644 index 00000000..674d3461 --- /dev/null +++ b/src/Parse/ParseConfig.php @@ -0,0 +1,41 @@ + + */ +class ParseConfig { + + private $currentConfig; + + /** + * Creates + */ + public function __construct() { + $result = ParseClient::_request("GET", "/1/config"); + $this->setConfig($result['params']); + } + + public function get($key) { + if (isset($this->currentConfig[$key])) { + return $this->currentConfig[$key]; + } + return null; + } + + public function escape($key) { + if (isset($this->currentConfig[$key])) { + return htmlentities($this->currentConfig[$key]); + } + return null; + } + + protected function setConfig($config) { + $this->currentConfig = $config; + } + +} \ No newline at end of file diff --git a/tests/ParseConfigTest.php b/tests/ParseConfigTest.php new file mode 100644 index 00000000..b48066c2 --- /dev/null +++ b/tests/ParseConfigTest.php @@ -0,0 +1,23 @@ +setConfig(["foo" => "bar", "some" => 1]); + } +} + +class ParseConfigTest extends PHPUnit_Framework_TestCase +{ + + public function testGetConfig() + { + $config = new ParseConfigMock(); + $this->assertEquals("bar", $config->get("foo")); + $this->assertEquals(1, $config->get("some")); + } + +} \ No newline at end of file