Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php /** * Copyright Magento, Inc. All rights reserved. * See COPYING.txt for license ..

Decoded Output download

<?php
/**
 * Copyright  Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Catalog\Model;

use Magento\Catalog\Model\ResourceModel\Product\Compare\CompareList as CompareListResource;
use Magento\Framework\Exception\LocalizedException;

/**
 *  CompareListId to MaskedListId resolver
 */
class CompareListIdToMaskedListId
{
    /**
     * @var CompareListFactory
     */
    private $compareListFactory;

    /**
     * @var CompareListResource
     */
    private $compareListResource;

    /**
     * @param CompareListFactory $compareListFactory
     * @param CompareListResource $compareListResource
     */
    public function __construct(
        CompareListFactory $compareListFactory,
        CompareListResource $compareListResource
    ) {
        $this->compareListFactory = $compareListFactory;
        $this->compareListResource = $compareListResource;
    }

    /**
     * Get listIdMask by listId
     *
     * @param int $listId
     *
     * @param int|null $customerId
     * @return null|string
     * @throws LocalizedException
     */
    public function execute(int $listId, int $customerId = null): ?string
    {
        $compareList = $this->compareListFactory->create();
        $this->compareListResource->load($compareList, $listId, 'list_id');
        if ((int)$compareList->getCustomerId() !== (int)$customerId) {
            throw new LocalizedException(__('This customer is not authorized to access this list'));
        }
        return $compareList->getListIdMask() ?? null;
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php
/**
 * Copyright  Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Catalog\Model;

use Magento\Catalog\Model\ResourceModel\Product\Compare\CompareList as CompareListResource;
use Magento\Framework\Exception\LocalizedException;

/**
 *  CompareListId to MaskedListId resolver
 */
class CompareListIdToMaskedListId
{
    /**
     * @var CompareListFactory
     */
    private $compareListFactory;

    /**
     * @var CompareListResource
     */
    private $compareListResource;

    /**
     * @param CompareListFactory $compareListFactory
     * @param CompareListResource $compareListResource
     */
    public function __construct(
        CompareListFactory $compareListFactory,
        CompareListResource $compareListResource
    ) {
        $this->compareListFactory = $compareListFactory;
        $this->compareListResource = $compareListResource;
    }

    /**
     * Get listIdMask by listId
     *
     * @param int $listId
     *
     * @param int|null $customerId
     * @return null|string
     * @throws LocalizedException
     */
    public function execute(int $listId, int $customerId = null): ?string
    {
        $compareList = $this->compareListFactory->create();
        $this->compareListResource->load($compareList, $listId, 'list_id');
        if ((int)$compareList->getCustomerId() !== (int)$customerId) {
            throw new LocalizedException(__('This customer is not authorized to access this list'));
        }
        return $compareList->getListIdMask() ?? null;
    }
}

Function Calls

None

Variables

None

Stats

MD5 4dd6d49b5299cb170997aac0fcdb69d2
Eval Count 0
Decode Time 86 ms