Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Util; Chris@0: Chris@0: /** Chris@0: * Contains utility methods for dealing with property paths. Chris@0: * Chris@0: * For more extensive functionality, use Symfony's PropertyAccess component. Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: class PropertyPath Chris@0: { Chris@0: /** Chris@0: * Appends a path to a given property path. Chris@0: * Chris@0: * If the base path is empty, the appended path will be returned unchanged. Chris@0: * If the base path is not empty, and the appended path starts with a Chris@0: * squared opening bracket ("["), the concatenation of the two paths is Chris@0: * returned. Otherwise, the concatenation of the two paths is returned, Chris@0: * separated by a dot ("."). Chris@0: * Chris@0: * @param string $basePath The base path Chris@0: * @param string $subPath The path to append Chris@0: * Chris@0: * @return string The concatenation of the two property paths Chris@0: */ Chris@0: public static function append($basePath, $subPath) Chris@0: { Chris@0: if ('' !== (string) $subPath) { Chris@0: if ('[' === $subPath[0]) { Chris@0: return $basePath.$subPath; Chris@0: } Chris@0: Chris@0: return '' !== (string) $basePath ? $basePath.'.'.$subPath : $subPath; Chris@0: } Chris@0: Chris@0: return $basePath; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Not instantiable. Chris@0: */ Chris@0: private function __construct() Chris@0: { Chris@0: } Chris@0: }