<commit_before><?php

namespace Shopware\Plugins\SwagPaymentPaypal\Components\Paypal;

use Shopware\Bundle\AccountBundle\Service\Validator\AddressValidatorInterface;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Components\DependencyInjection\Container as DIContainer;
use Shopware\Models\Customer\Address;
use Symfony\Component\Validator\ConstraintViolationInterface;

class AddressValidator implements AddressValidatorInterface
{
    /** @var  AddressValidatorInterface */
    private $innerValidator;

    /** @var  DIContainer $container */
    private $container;

    /**
     * PaypalAddressValidator constructor.
     *
     * @param AddressValidatorInterface $innerValidator
     * @param DIContainer $container
     */
    public function __construct(AddressValidatorInterface $innerValidator, DIContainer $container)
    {
        $this->innerValidator = $innerValidator;
        $this->container = $container;
    }

    /**
     * @param Address $address
     * @throws ValidationException
     */
    public function validate(Address $address)
    {
        if (!$this->container->get('front')->Request()
            || $this->container->get('front')->Request()->getControllerName() !== 'payment_paypal'
        ) {
            $this->innerValidator->validate($address);<commit_msg>PT-8092 - fix checking for controller name in address validator decorator<commit_after><?php

namespace Shopware\Plugins\SwagPaymentPaypal\Components\Paypal;

use Shopware\Bundle\AccountBundle\Service\Validator\AddressValidatorInterface;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Components\DependencyInjection\Container as DIContainer;
use Shopware\Models\Customer\Address;
use Symfony\Component\Validator\ConstraintViolationInterface;

class AddressValidator implements AddressValidatorInterface
{
    /** @var  AddressValidatorInterface */
    private $innerValidator;

    /** @var  DIContainer $container */
    private $container;

    /**
     * PaypalAddressValidator constructor.
     *
     * @param AddressValidatorInterface $innerValidator
     * @param DIContainer $container
     */
    public function __construct(AddressValidatorInterface $innerValidator, DIContainer $container)
    {
        $this->innerValidator = $innerValidator;
        $this->container = $container;
    }

    /**
     * @param Address $address
     * @throws ValidationException
     */
    public function validate(Address $address)
    {
        $request = $this->container->get('front')->Request();
        if (!$request) {
            $this->innerValidator->validate($address);

            return;
        }

        $controllerName = $request->getControllerName();
        $payPalController = array('payment_paypal', 'paymentpaypal');
        if (!in_array(strtolower($controllerName), $payPalController, true)) {
            $this->innerValidator->validate($address);
{'fraction_non_alphanumeric': 0.10932145305003427, 'fraction_numerical': 0.0013708019191226869, 'mean_word_length': 3.7309562398703404, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1066780', 'n_tokens_mistral': 726, 'n_tokens_neox': 735, 'n_words': 139}