CoreFiles by mySites.guru
PropertyPath.php51 lines, 1,335 bytes, from Joomla_5.3.2-Stable-Full_Package.zip
Raw History Compare with 5.3.1
md5
2363053ac3f6b5152ba60205dd7adebb
sha1
c8d8faf9c49e04a77862c7297b6ee6465685c359
sha256
2d97bb741582d90db499732c558952fbc0d70ebb4c368108d4fcb2ab71b5c6f7
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Validator\Util;

/**
 * Contains utility methods for dealing with property paths.
 *
 * For more extensive functionality, use Symfony's PropertyAccess component.
 *
 * @author Bernhard Schussek <[email protected]>
 */
class PropertyPath
{
    /**
     * Appends a path to a given property path.
     *
     * If the base path is empty, the appended path will be returned unchanged.
     * If the base path is not empty, and the appended path starts with a
     * squared opening bracket ("["), the concatenation of the two paths is
     * returned. Otherwise, the concatenation of the two paths is returned,
     * separated by a dot (".").
     */
    public static function append(string $basePath, string $subPath): string
    {
        if ('' !== $subPath) {
            if ('[' === $subPath[0]) {
                return $basePath.$subPath;
            }

            return '' !== $basePath ? $basePath.'.'.$subPath : $subPath;
        }

        return $basePath;
    }

    /**
     * Not instantiable.
     */
    private function __construct()
    {
    }
}

The same content is in 136 releases, Joomla 5.1.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.