1 <?php
2 /**
3 * ArangoDB-PHP-Core client: UpdatePolicy
4 *
5 * Taken from the original ArangoDB-Client, in order to maintain easy migration. Thanks Jan ;)
6 *
7 * @author Frank Mayer
8 * @copyright Copyright 2013-2015, FRANKMAYER.NET, Athens, Greece
9 */
10
11 namespace frankmayer\ArangoDbPhpCore\Config;
12
13 use frankmayer\ArangoDbPhpCore\ClientException;
14
15 /**
16 * Document update policies
17 *
18 * @package frankmayer\ArangoDbPhpCore\Config
19 */
20 class UpdatePolicy
21 {
22 /**
23 * last update will win in case of conflicting versions
24 */
25 const LAST = 'last';
26
27 /**
28 * an error will be returned in case of conflicting versions
29 */
30 const ERROR = 'error';
31
32 /**
33 * Check if the supplied policy value is valid
34 *
35 * @throws ClientException
36 *
37 * @param string $value - update policy value
38 *
39 * @return void
40 */
41 public static function validate($value)
42 {
43 assert(is_string($value));
44
45 if (!in_array($value, [self::LAST, self::ERROR])) {
46 throw new ClientException('Invalid update policy');
47 }
48 }
49 }
50