Skip to content

Commit 3eee7c9

Browse files
authored
Merge pull request #105 from localheinz/fix/one-class-per-file
Fix: Declare a single class per file
2 parents bc8fa25 + 9e9673d commit 3eee7c9

15 files changed

+372
-346
lines changed

src/LaunchDarkly/EvalResult.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace LaunchDarkly;
4+
5+
class EvalResult
6+
{
7+
private $_variation = null;
8+
private $_value = null;
9+
/** @var array */
10+
private $_prerequisiteEvents = [];
11+
12+
/**
13+
* EvalResult constructor.
14+
* @param null $value
15+
* @param array $prerequisiteEvents
16+
*/
17+
public function __construct($variation, $value, array $prerequisiteEvents)
18+
{
19+
$this->_variation = $variation;
20+
$this->_value = $value;
21+
$this->_prerequisiteEvents = $prerequisiteEvents;
22+
}
23+
24+
/**
25+
* @return int
26+
*/
27+
public function getVariation()
28+
{
29+
return $this->_variation;
30+
}
31+
32+
/**
33+
* @return null
34+
*/
35+
public function getValue()
36+
{
37+
return $this->_value;
38+
}
39+
40+
/**
41+
* @return array
42+
*/
43+
public function getPrerequisiteEvents()
44+
{
45+
return $this->_prerequisiteEvents;
46+
}
47+
}

src/LaunchDarkly/FeatureFlag.php

Lines changed: 0 additions & 194 deletions
Original file line numberDiff line numberDiff line change
@@ -223,197 +223,3 @@ public function isDeleted()
223223
return $this->_deleted;
224224
}
225225
}
226-
227-
class EvalResult
228-
{
229-
private $_variation = null;
230-
private $_value = null;
231-
/** @var array */
232-
private $_prerequisiteEvents = [];
233-
234-
/**
235-
* EvalResult constructor.
236-
* @param null $value
237-
* @param array $prerequisiteEvents
238-
*/
239-
public function __construct($variation, $value, array $prerequisiteEvents)
240-
{
241-
$this->_variation = $variation;
242-
$this->_value = $value;
243-
$this->_prerequisiteEvents = $prerequisiteEvents;
244-
}
245-
246-
/**
247-
* @return int
248-
*/
249-
public function getVariation()
250-
{
251-
return $this->_variation;
252-
}
253-
254-
/**
255-
* @return null
256-
*/
257-
public function getValue()
258-
{
259-
return $this->_value;
260-
}
261-
262-
/**
263-
* @return array
264-
*/
265-
public function getPrerequisiteEvents()
266-
{
267-
return $this->_prerequisiteEvents;
268-
}
269-
}
270-
271-
class WeightedVariation
272-
{
273-
/** @var int */
274-
private $_variation = null;
275-
/** @var int */
276-
private $_weight = null;
277-
278-
private function __construct($variation, $weight)
279-
{
280-
$this->_variation = $variation;
281-
$this->_weight = $weight;
282-
}
283-
284-
public static function getDecoder()
285-
{
286-
return function ($v) {
287-
return new WeightedVariation($v['variation'], $v['weight']);
288-
};
289-
}
290-
291-
/**
292-
* @return int
293-
*/
294-
public function getVariation()
295-
{
296-
return $this->_variation;
297-
}
298-
299-
/**
300-
* @return int
301-
*/
302-
public function getWeight()
303-
{
304-
return $this->_weight;
305-
}
306-
}
307-
308-
class Target
309-
{
310-
/** @var string[] */
311-
private $_values = array();
312-
/** @var int */
313-
private $_variation = null;
314-
315-
protected function __construct(array $values, $variation)
316-
{
317-
$this->_values = $values;
318-
$this->_variation = $variation;
319-
}
320-
321-
public static function getDecoder()
322-
{
323-
return function ($v) {
324-
return new Target($v['values'], $v['variation']);
325-
};
326-
}
327-
328-
/**
329-
* @return \string[]
330-
*/
331-
public function getValues()
332-
{
333-
return $this->_values;
334-
}
335-
336-
/**
337-
* @return int
338-
*/
339-
public function getVariation()
340-
{
341-
return $this->_variation;
342-
}
343-
}
344-
345-
class Prerequisite
346-
{
347-
/** @var string */
348-
private $_key = null;
349-
/** @var int */
350-
private $_variation = null;
351-
352-
protected function __construct($key, $variation)
353-
{
354-
$this->_key = $key;
355-
$this->_variation = $variation;
356-
}
357-
358-
public static function getDecoder()
359-
{
360-
return function ($v) {
361-
return new Prerequisite($v['key'], $v['variation']);
362-
};
363-
}
364-
365-
/**
366-
* @return string
367-
*/
368-
public function getKey()
369-
{
370-
return $this->_key;
371-
}
372-
373-
/**
374-
* @return int
375-
*/
376-
public function getVariation()
377-
{
378-
return $this->_variation;
379-
}
380-
}
381-
382-
class Rollout
383-
{
384-
/** @var WeightedVariation[] */
385-
private $_variations = array();
386-
/** @var string */
387-
private $_bucketBy = null;
388-
389-
protected function __construct(array $variations, $bucketBy)
390-
{
391-
$this->_variations = $variations;
392-
$this->_bucketBy = $bucketBy;
393-
}
394-
395-
public static function getDecoder()
396-
{
397-
return function ($v) {
398-
return new Rollout(
399-
array_map(WeightedVariation::getDecoder(), $v['variations']),
400-
isset($v['bucketBy']) ? $v['bucketBy'] : null);
401-
};
402-
}
403-
404-
/**
405-
* @return WeightedVariation[]
406-
*/
407-
public function getVariations()
408-
{
409-
return $this->_variations;
410-
}
411-
412-
/**
413-
* @return string
414-
*/
415-
public function getBucketBy()
416-
{
417-
return $this->_bucketBy;
418-
}
419-
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
namespace LaunchDarkly;
3+
4+
/**
5+
* Used internally.
6+
*/
7+
class InvalidSDKKeyException extends \Exception
8+
{
9+
}

src/LaunchDarkly/LDClient.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55
use Monolog\Logger;
66
use Psr\Log\LoggerInterface;
77

8-
/**
9-
* Used internally.
10-
*/
11-
class InvalidSDKKeyException extends \Exception
12-
{
13-
}
14-
158
/**
169
* A client for the LaunchDarkly API.
1710
*/

src/LaunchDarkly/Prerequisite.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
namespace LaunchDarkly;
3+
4+
class Prerequisite
5+
{
6+
/** @var string */
7+
private $_key = null;
8+
/** @var int */
9+
private $_variation = null;
10+
11+
protected function __construct($key, $variation)
12+
{
13+
$this->_key = $key;
14+
$this->_variation = $variation;
15+
}
16+
17+
public static function getDecoder()
18+
{
19+
return function ($v) {
20+
return new Prerequisite($v['key'], $v['variation']);
21+
};
22+
}
23+
24+
/**
25+
* @return string
26+
*/
27+
public function getKey()
28+
{
29+
return $this->_key;
30+
}
31+
32+
/**
33+
* @return int
34+
*/
35+
public function getVariation()
36+
{
37+
return $this->_variation;
38+
}
39+
}

src/LaunchDarkly/Rollout.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
namespace LaunchDarkly;
3+
4+
class Rollout
5+
{
6+
/** @var WeightedVariation[] */
7+
private $_variations = array();
8+
/** @var string */
9+
private $_bucketBy = null;
10+
11+
protected function __construct(array $variations, $bucketBy)
12+
{
13+
$this->_variations = $variations;
14+
$this->_bucketBy = $bucketBy;
15+
}
16+
17+
public static function getDecoder()
18+
{
19+
return function ($v) {
20+
return new Rollout(
21+
array_map(WeightedVariation::getDecoder(), $v['variations']),
22+
isset($v['bucketBy']) ? $v['bucketBy'] : null);
23+
};
24+
}
25+
26+
/**
27+
* @return WeightedVariation[]
28+
*/
29+
public function getVariations()
30+
{
31+
return $this->_variations;
32+
}
33+
34+
/**
35+
* @return string
36+
*/
37+
public function getBucketBy()
38+
{
39+
return $this->_bucketBy;
40+
}
41+
}

0 commit comments

Comments
 (0)