* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ namespace PrestaShop\PrestaShop\Core\Domain\Feature\Command; use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; /** * Adds new feature */ class AddFeatureCommand { /** * @var string[] */ private $localizedNames; /** * @var int[] */ private $shopAssociation; /** * @param string[] $localizedNames * @param int[] $shopAssociation */ public function __construct(array $localizedNames, array $shopAssociation = []) { $this->assertNamesAreValid($localizedNames); $this->localizedNames = $localizedNames; $this->shopAssociation = $shopAssociation; } /** * @return string[] */ public function getLocalizedNames() { return $this->localizedNames; } /** * @return int[] */ public function getShopAssociation() { return $this->shopAssociation; } /** * Asserts that feature names are valid. * * @param string[] $names * * @throws FeatureConstraintException */ private function assertNamesAreValid(array $names) { if (empty($names)) { throw new FeatureConstraintException('Feature name cannot be empty', FeatureConstraintException::EMPTY_NAME); } } }