comparison vendor/symfony/validator/Util/PropertyPath.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Validator\Util;
13
14 /**
15 * Contains utility methods for dealing with property paths.
16 *
17 * For more extensive functionality, use Symfony's PropertyAccess component.
18 *
19 * @author Bernhard Schussek <bschussek@gmail.com>
20 */
21 class PropertyPath
22 {
23 /**
24 * Appends a path to a given property path.
25 *
26 * If the base path is empty, the appended path will be returned unchanged.
27 * If the base path is not empty, and the appended path starts with a
28 * squared opening bracket ("["), the concatenation of the two paths is
29 * returned. Otherwise, the concatenation of the two paths is returned,
30 * separated by a dot (".").
31 *
32 * @param string $basePath The base path
33 * @param string $subPath The path to append
34 *
35 * @return string The concatenation of the two property paths
36 */
37 public static function append($basePath, $subPath)
38 {
39 if ('' !== (string) $subPath) {
40 if ('[' === $subPath[0]) {
41 return $basePath.$subPath;
42 }
43
44 return '' !== (string) $basePath ? $basePath.'.'.$subPath : $subPath;
45 }
46
47 return $basePath;
48 }
49
50 /**
51 * Not instantiable.
52 */
53 private function __construct()
54 {
55 }
56 }