1 | <?php |
||
18 | trait WriteConcernConverter |
||
19 | { |
||
20 | /** |
||
21 | * @param string|int|bool $wstring |
||
22 | * @param int $wtimeout |
||
23 | * @return \MongoDB\Driver\WriteConcern |
||
24 | */ |
||
25 | 252 | protected function createWriteConcernFromParameters($wstring, $wtimeout) |
|
26 | { |
||
27 | // Convert legacy write concern |
||
28 | 252 | if (is_bool($wstring)) { |
|
29 | 2 | $wstring = (int) $wstring; |
|
30 | } |
||
31 | |||
32 | 252 | if (! is_string($wstring) && ! is_int($wstring)) { |
|
33 | trigger_error("w for WriteConcern must be a string or integer", E_USER_WARNING); |
||
34 | return false; |
||
35 | } |
||
36 | |||
37 | // Ensure wtimeout is not < 0 |
||
38 | 252 | return new \MongoDB\Driver\WriteConcern($wstring, max($wtimeout, 0)); |
|
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param array $writeConcernArray |
||
43 | * @return \MongoDB\Driver\WriteConcern |
||
44 | */ |
||
45 | 251 | protected function createWriteConcernFromArray($writeConcernArray) |
|
52 | } |
||
53 |