-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathKey.php
More file actions
92 lines (82 loc) · 2.2 KB
/
Copy pathKey.php
File metadata and controls
92 lines (82 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace SplitIO\Sdk;
use SplitIO\Sdk\Validator\InputValidator;
use SplitIO\Exception\KeyException;
/**
* Class Key
* @package SplitIO\Sdk
*/
class Key
{
/**
* @var
*/
private $matchingKey;
/**
* @var
*/
private $bucketingKey;
/**
* Key constructor.
* @param string $matchingKey
* @param string $bucketingKey
* @throws KeyException
*/
public function __construct($matchingKey, $bucketingKey)
{
$strMatchingKey = InputValidator::toString($matchingKey, "matchingKey", "Key");
if ($strMatchingKey === false) {
throw new KeyException('Key: you passed an invalid matchingKey type, matchingKey '
. 'must be a non-empty string.');
}
if (empty($strMatchingKey)) {
throw new KeyException('Key: you passed an empty string, matchingKey must be a non-empty string.');
}
$this->matchingKey = $strMatchingKey;
$strBucketingKey = InputValidator::toString($bucketingKey, "bucketingKey", "Key");
if ($strBucketingKey === false) {
throw new KeyException('Key: you passed an invalid bucketingKey type, bucketingKey '
. 'must be a non-empty string.');
}
if (empty($strBucketingKey)) {
throw new KeyException('Key: you passed an empty string, bucketingKey must be a non-empty '
. 'string.');
}
$this->bucketingKey = $bucketingKey;
}
/**
* @return mixed
*/
public function getMatchingKey()
{
return $this->matchingKey;
}
/**
* @param mixed $matchingKey
*/
public function setMatchingKey($matchingKey)
{
$this->matchingKey = $matchingKey;
}
/**
* @return mixed
*/
public function getBucketingKey()
{
return $this->bucketingKey;
}
/**
* @param mixed $bucketingKey
*/
public function setBucketingKey($bucketingKey)
{
$this->bucketingKey = $bucketingKey;
}
/**
* @return string
*/
public function __toString()
{
return sprintf("Matching key: %s -- Bucketing key: %s", $this->matchingKey, $this->bucketingKey);
}
}