Skip to content

Commit bd851a9

Browse files
PSR 2 standards
1 parent e72722e commit bd851a9

14 files changed

+237
-138
lines changed

src/LaunchDarkly/ApcLDDFeatureRequester.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22
namespace LaunchDarkly;
33

4-
54
/**
65
* Feature requester from an LDD-populated redis, with APC caching
76
* @deprecated Per the docs (http://php.net/manual/en/intro.apc.php):
@@ -10,10 +9,12 @@
109
*
1110
* @package LaunchDarkly
1211
*/
13-
class ApcLDDFeatureRequester extends LDDFeatureRequester {
12+
class ApcLDDFeatureRequester extends LDDFeatureRequester
13+
{
1414
protected $_expiration = 30;
1515

16-
function __construct($baseUri, $sdkKey, $options) {
16+
public function __construct($baseUri, $sdkKey, $options)
17+
{
1718
parent::__construct($baseUri, $sdkKey, $options);
1819

1920
if (isset($options['apc_expiration'])) {
@@ -31,13 +32,13 @@ protected function fetch($key, &$success = null)
3132
return \apc_fetch($key, $success);
3233
}
3334

34-
protected function get_from_cache($key) {
35+
protected function get_from_cache($key)
36+
{
3537
$key = self::make_cache_key($key);
3638
$enabled = $this->fetch($key);
3739
if ($enabled === false) {
3840
return null;
39-
}
40-
else {
41+
} else {
4142
return $enabled;
4243
}
4344
}
@@ -53,11 +54,13 @@ protected function add($key, $var, $ttl = 0)
5354
return \apc_add($key, $var, $ttl);
5455
}
5556

56-
protected function store_in_cache($key, $val) {
57+
protected function store_in_cache($key, $val)
58+
{
5759
$this->add($this->make_cache_key($key), $val, $this->_expiration);
5860
}
5961

60-
private function make_cache_key($name) {
62+
private function make_cache_key($name)
63+
{
6164
return $this->_features_key.'.'.$name;
6265
}
63-
}
66+
}

src/LaunchDarkly/CurlEventPublisher.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,25 @@ class CurlEventPublisher implements EventPublisher
1919
private $_ssl;
2020
private $_curl = '/usr/bin/env curl';
2121

22-
function __construct($sdkKey, array $options = array()) {
22+
public function __construct($sdkKey, array $options = array())
23+
{
2324
$this->_sdkKey = $sdkKey;
2425

2526
$eventsUri = LDClient::DEFAULT_EVENTS_URI;
2627
if (isset($options['events_uri'])) {
2728
$eventsUri = $options['events_uri'];
2829
}
29-
$url = parse_url(rtrim($eventsUri,'/'));
30+
$url = parse_url(rtrim($eventsUri, '/'));
3031
$this->_host = $url['host'];
3132
$this->_ssl = $url['scheme'] === 'https';
3233
if (isset($url['port'])) {
3334
$this->_port = $url['port'];
34-
}
35-
else {
35+
} else {
3636
$this->_port = $this->_ssl ? 443 : 80;
3737
}
3838
if (isset($url['path'])) {
3939
$this->_path = $url['path'];
40-
}
41-
else {
40+
} else {
4241
$this->_path = '';
4342
}
4443

@@ -47,13 +46,15 @@ function __construct($sdkKey, array $options = array()) {
4746
}
4847
}
4948

50-
public function publish($payload) {
49+
public function publish($payload)
50+
{
5151
$args = $this->createArgs($payload);
5252

5353
return $this->makeRequest($args);
5454
}
5555

56-
private function createArgs($payload) {
56+
private function createArgs($payload)
57+
{
5758
$scheme = $this->_ssl ? "https://" : "http://";
5859
$args = " -X POST";
5960
$args.= " -H 'Content-Type: application/json'";
@@ -65,9 +66,10 @@ private function createArgs($payload) {
6566
return $args;
6667
}
6768

68-
private function makeRequest($args) {
69+
private function makeRequest($args)
70+
{
6971
$cmd = $this->_curl . " " . $args . ">> /dev/null 2>&1 &";
7072
shell_exec($cmd);
7173
return true;
7274
}
73-
}
75+
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<?php
22
namespace LaunchDarkly;
33

4-
54
use Exception;
65

7-
class EvaluationException extends Exception {
6+
class EvaluationException extends Exception
7+
{
88
/**
99
* EvaluationException constructor.
1010
* @param string $message
1111
*/
12-
public function __construct($message) {
12+
public function __construct($message)
13+
{
1314
parent::__construct($message);
1415
}
15-
}
16+
}

src/LaunchDarkly/EventPublisher.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
/**
55
* Provides a transport mechanism for sending events to the LaunchDarkly service.
66
*/
7-
interface EventPublisher {
7+
interface EventPublisher
8+
{
89
/**
910
* @param string $sdkKey The SDK key for your account
1011
* @param mixed[] $options Client configuration settings
@@ -18,4 +19,4 @@ public function __construct($sdkKey, array $options);
1819
* @return bool Whether the events were successfully published
1920
*/
2021
public function publish($payload);
21-
}
22+
}

0 commit comments

Comments
 (0)