4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator\Util;
15 * Contains utility methods for dealing with property paths.
17 * For more extensive functionality, use Symfony's PropertyAccess component.
19 * @author Bernhard Schussek <bschussek@gmail.com>
24 * Appends a path to a given property path.
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 (".").
32 * @param string $basePath The base path
33 * @param string $subPath The path to append
35 * @return string The concatenation of the two property paths
37 public static function append($basePath, $subPath)
39 if ('' !== (string) $subPath) {
40 if ('[' === $subPath[0]) {
41 return $basePath.$subPath;
44 return '' !== (string) $basePath ? $basePath.'.'.$subPath : $subPath;
53 private function __construct()