HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/magento/module-customer/Model/Options.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Customer\Model;

use Magento\Config\Model\Config\Source\Nooptreq as NooptreqSource;
use Magento\Customer\Helper\Address as AddressHelper;
use Magento\Framework\Escaper;
use Magento\Store\Api\Data\StoreInterface;

/**
 * Customer Options.
 */
class Options
{
    /**
     * Customer address
     *
     * @var AddressHelper
     */
    protected $addressHelper;

    /**
     * @var Escaper
     */
    protected $escaper;

    /**
     * @param AddressHelper $addressHelper
     * @param Escaper $escaper
     */
    public function __construct(
        AddressHelper $addressHelper,
        Escaper $escaper
    ) {
        $this->addressHelper = $addressHelper;
        $this->escaper = $escaper;
    }

    /**
     * Retrieve name prefix dropdown options
     *
     * @param null|string|bool|int|StoreInterface $store
     * @return array|bool
     */
    public function getNamePrefixOptions($store = null)
    {
        return $this->prepareNamePrefixSuffixOptions(
            $this->addressHelper->getConfig('prefix_options', $store),
            $this->addressHelper->getConfig('prefix_show', $store) == NooptreqSource::VALUE_OPTIONAL
        );
    }

    /**
     * Retrieve name suffix dropdown options
     *
     * @param null|string|bool|int|StoreInterface $store
     * @return array|bool
     */
    public function getNameSuffixOptions($store = null)
    {
        return $this->prepareNamePrefixSuffixOptions(
            $this->addressHelper->getConfig('suffix_options', $store),
            $this->addressHelper->getConfig('suffix_show', $store) == NooptreqSource::VALUE_OPTIONAL
        );
    }

    /**
     * Unserialize and clear name prefix or suffix options.
     *
     * @param string $options
     * @param bool $isOptional
     * @return array|bool
     *
     * @deprecated 101.0.4
     * @see prepareNamePrefixSuffixOptions()
     */
    protected function _prepareNamePrefixSuffixOptions($options, $isOptional = false)
    {
        return $this->prepareNamePrefixSuffixOptions($options, $isOptional);
    }

    /**
     * Unserialize and clear name prefix or suffix options
     *
     * If field is optional, add an empty first option.
     *
     * @param string $options
     * @param bool $isOptional
     * @return array|bool
     */
    private function prepareNamePrefixSuffixOptions($options, $isOptional = false)
    {
        $options = trim($options);
        if (empty($options)) {
            return false;
        }

        $result = [];
        $options = explode(';', $options);
        foreach ($options as $value) {
            $result[] = $this->escaper->escapeHtml(trim($value)) ?: ' ';
        }

        if ($isOptional && trim(current($options))) {
            $result = array_merge([' '], $result);
        }

        return $result;
    }
}