Skip to content

Commit 06e82f7

Browse files
committed
Merge branch 'master'
2 parents 7533d22 + 36aaa08 commit 06e82f7

28 files changed

+524
-304
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to the LaunchDarkly PHP SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [2.4.0] - 2018-01-04
6+
### Added
7+
- Support for [private user attributes](https://docs.launchdarkly.com/docs/private-user-attributes).
8+
9+
### Changed
10+
- Stop retrying HTTP requests if the API key has been invalidated.
11+
- User bucketing supports integer attributes. Thanks @mlund01!
12+
- Source code complies with the PSR-2 standard. Thanks @valerianpereira!
13+
14+
### Fixed
15+
- The PSR-4 autoloading specification is now correct. Thanks @jenssegers!
16+
517
## [2.3.0] - 2017-10-06
618
### Added
719
- New `flush` method forces events to be published to the LaunchDarkly service. This can be useful if `LDClient` is not automatically destroyed at the end of a request. Thanks @foxted!

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.3.0
1+
2.4.0

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ test:
2828

2929
- docker run -it -v `pwd`:/php-client nyanpass/php5.5:5.5-alpine sh -c "curl -s https://getcomposer.org/installer | php && cd /php-client && /composer.phar update && vendor/bin/phpunit"
3030
- docker run -it -v `pwd`:/php-client nyanpass/php5.5:5.5-alpine sh -c "curl -s https://getcomposer.org/installer | php && cd /php-client && /composer.phar update --prefer-lowest && vendor/bin/phpunit"
31+

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"autoload": {
3535
"psr-4": {
36-
"": "src/"
36+
"LaunchDarkly\\": "src/LaunchDarkly/"
3737
}
3838
},
3939
"autoload-dev": {

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/Clause.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace LaunchDarkly;
44

5-
class Clause {
5+
class Clause
6+
{
67
/** @var string */
78
private $_attribute = null;
89
/** @var string */
@@ -12,14 +13,16 @@ class Clause {
1213
/** @var bool */
1314
private $_negate = false;
1415

15-
private function __construct($attribute, $op, array $values, $negate) {
16+
private function __construct($attribute, $op, array $values, $negate)
17+
{
1618
$this->_attribute = $attribute;
1719
$this->_op = $op;
1820
$this->_values = $values;
1921
$this->_negate = $negate;
2022
}
2123

22-
public static function getDecoder() {
24+
public static function getDecoder()
25+
{
2326
return function ($v) {
2427
return new Clause($v['attribute'], $v['op'], $v['values'], $v['negate']);
2528
};
@@ -29,7 +32,8 @@ public static function getDecoder() {
2932
* @param $user LDUser
3033
* @return bool
3134
*/
32-
public function matchesUser($user) {
35+
public function matchesUser($user)
36+
{
3337
$userValue = $user->getValueForEvaluation($this->_attribute);
3438
if ($userValue === null) {
3539
return false;
@@ -50,36 +54,41 @@ public function matchesUser($user) {
5054
/**
5155
* @return string
5256
*/
53-
public function getAttribute() {
57+
public function getAttribute()
58+
{
5459
return $this->_attribute;
5560
}
5661

5762
/**
5863
* @return string
5964
*/
60-
public function getOp() {
65+
public function getOp()
66+
{
6167
return $this->_op;
6268
}
6369

6470
/**
6571
* @return array
6672
*/
67-
public function getValues() {
73+
public function getValues()
74+
{
6875
return $this->_values;
6976
}
7077

7178
/**
7279
* @return boolean
7380
*/
74-
public function isNegate() {
81+
public function isNegate()
82+
{
7583
return $this->_negate;
7684
}
7785

7886
/**
7987
* @param $userValue
8088
* @return bool
8189
*/
82-
private function matchAny($userValue) {
90+
private function matchAny($userValue)
91+
{
8392
foreach ($this->_values as $v) {
8493
$result = Operators::apply($this->_op, $userValue, $v);
8594
if ($result === true) {
@@ -89,11 +98,12 @@ private function matchAny($userValue) {
8998
return false;
9099
}
91100

92-
private function _maybeNegate($b) {
101+
private function _maybeNegate($b)
102+
{
93103
if ($this->_negate) {
94104
return !$b;
95105
} else {
96106
return $b;
97107
}
98108
}
99-
}
109+
}

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+
}

0 commit comments

Comments
 (0)