Skip to content

Commit 0171095

Browse files
author
Fosco Marotto
committed
Merge branch 'master' of github.com:ParsePlatform/parse-php-sdk
2 parents cb75cbe + faed2fb commit 0171095

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/Parse/ParseConfig.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace Parse;
4+
5+
/**
6+
* ParseConfig - For accessing Parse Config settings
7+
*
8+
* @package Parse
9+
* @author Fosco Marotto <fjm@fb.com>
10+
*/
11+
class ParseConfig {
12+
13+
private $currentConfig;
14+
15+
/**
16+
* Creates
17+
*/
18+
public function __construct() {
19+
$result = ParseClient::_request("GET", "/1/config");
20+
$this->setConfig($result['params']);
21+
}
22+
23+
public function get($key) {
24+
if (isset($this->currentConfig[$key])) {
25+
return $this->currentConfig[$key];
26+
}
27+
return null;
28+
}
29+
30+
public function escape($key) {
31+
if (isset($this->currentConfig[$key])) {
32+
return htmlentities($this->currentConfig[$key]);
33+
}
34+
return null;
35+
}
36+
37+
protected function setConfig($config) {
38+
$this->currentConfig = $config;
39+
}
40+
41+
}

tests/ParseConfigTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Parse\ParseConfig;
4+
5+
require_once 'ParseTestHelper.php';
6+
7+
class ParseConfigMock extends ParseConfig {
8+
public function __construct() {
9+
$this->setConfig(["foo" => "bar", "some" => 1]);
10+
}
11+
}
12+
13+
class ParseConfigTest extends PHPUnit_Framework_TestCase
14+
{
15+
16+
public function testGetConfig()
17+
{
18+
$config = new ParseConfigMock();
19+
$this->assertEquals("bar", $config->get("foo"));
20+
$this->assertEquals(1, $config->get("some"));
21+
}
22+
23+
}

0 commit comments

Comments
 (0)