Symfony\Component\PropertyAccess\PropertyAccessor::getPropertyPath PHP Method

getPropertyPath() private method

Gets a PropertyPath instance and caches it.
private getPropertyPath ( string | Symfony\Component\PropertyAccess\PropertyPath $propertyPath ) : Symfony\Component\PropertyAccess\PropertyPath
$propertyPath string | Symfony\Component\PropertyAccess\PropertyPath
return Symfony\Component\PropertyAccess\PropertyPath
    private function getPropertyPath($propertyPath)
    {
        if ($propertyPath instanceof PropertyPathInterface) {
            // Don't call the copy constructor has it is not needed here
            return $propertyPath;
        }

        if (isset($this->propertyPathCache[$propertyPath])) {
            return $this->propertyPathCache[$propertyPath];
        }

        if ($this->cacheItemPool) {
            $item = $this->cacheItemPool->getItem(self::CACHE_PREFIX_PROPERTY_PATH.$propertyPath);
            if ($item->isHit()) {
                return $this->propertyPathCache[$propertyPath] = $item->get();
            }
        }

        $propertyPathInstance = new PropertyPath($propertyPath);
        if (isset($item)) {
            $item->set($propertyPathInstance);
            $this->cacheItemPool->save($item);
        }

        return $this->propertyPathCache[$propertyPath] = $propertyPathInstance;
    }