1<?php
2
3/**
4 * Copyright since 2007 PrestaShop SA and Contributors
5 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
6 *
7 * NOTICE OF LICENSE
8 *
9 * This source file is subject to the Open Software License (OSL 3.0)
10 * that is bundled with this package in the file LICENSE.md.
11 * It is also available through the world-wide-web at this URL:
12 * https://opensource.org/licenses/OSL-3.0
13 * If you did not receive a copy of the license and are unable to
14 * obtain it through the world-wide-web, please send an email
15 * to license@prestashop.com so we can send you a copy immediately.
16 *
17 * DISCLAIMER
18 *
19 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
20 * versions in the future. If you wish to customize PrestaShop for your
21 * needs please refer to https://devdocs.prestashop.com/ for more information.
22 *
23 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
24 * @copyright Since 2007 PrestaShop SA and Contributors
25 * @license   https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
26 */
27
28namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject;
29
30use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\InvalidShowcaseCardNameException;
31
32/**
33 * Showcase cards are help dialogs that appear at the top of pages to guide the merchant
34 */
35class ShowcaseCard
36{
37    /**
38     * Card shown in SEO & URLs
39     */
40    public const SEO_URLS_CARD = 'seo-urls_card';
41
42    /**
43     * Card shown in Categories
44     */
45    public const CATEGORIES_CARD = 'categories_card';
46
47    /**
48     * Card shown in Customers
49     */
50    public const CUSTOMERS_CARD = 'customers_card';
51
52    /**
53     * Card shown in Employees
54     */
55    public const EMPLOYEES_CARD = 'employees_card';
56
57    /**
58     * Card shown in Improve -> Design -> Pages
59     */
60    public const CMS_PAGES_CARD = 'cms-pages_card';
61
62    /**
63     * Card shown in Sell -> Catalog -> Attributes & features -> Attributes
64     */
65    public const ATTRIBUTES_CARD = 'attributes_card';
66
67    /**
68     * Card shown in Sell -> Catalog -> Monitoring
69     */
70    public const MONITORING_CARD = 'monitoring_card';
71
72    /**
73     * Card shown in Improve -> Shipping -> Carriers
74     */
75    const CARRIERS_CARD = 'carriers_card';
76
77    /**
78     * List of supported card names
79     */
80    public const SUPPORTED_NAMES = [
81        self::SEO_URLS_CARD => true,
82        self::CATEGORIES_CARD => true,
83        self::CUSTOMERS_CARD => true,
84        self::EMPLOYEES_CARD => true,
85        self::CMS_PAGES_CARD => true,
86        self::ATTRIBUTES_CARD => true,
87        self::MONITORING_CARD => true,
88        self::CARRIERS_CARD => true,
89    ];
90
91    /**
92     * @var string
93     */
94    private $name;
95
96    /**
97     * ShowcaseCardName constructor.
98     *
99     * @param string $name Showcase card name
100     *
101     * @throws InvalidShowcaseCardNameException
102     */
103    public function __construct($name)
104    {
105        if (!$this->isSupported($name)) {
106            throw new InvalidShowcaseCardNameException(sprintf('Unsupported showcase card name: %s', print_r($name, true)));
107        }
108
109        $this->name = $name;
110    }
111
112    /**
113     * @return string
114     */
115    public function getName()
116    {
117        return $this->name;
118    }
119
120    /**
121     * Indicates if the provided name matches an existing showcase card
122     *
123     * @param string $name
124     *
125     * @return bool
126     */
127    private function isSupported($name)
128    {
129        return array_key_exists($name, self::SUPPORTED_NAMES);
130    }
131}
132