N98\Magento\Command\Config\AbstractConfigCommand::_convertScopeIdParam PHP Method

_convertScopeIdParam() protected method

protected _convertScopeIdParam ( string $scope, string $scopeId, boolean $allowZeroScope = false ) : string
$scope string
$scopeId string
$allowZeroScope boolean
return string non-negative integer number
    protected function _convertScopeIdParam($scope, $scopeId, $allowZeroScope = false)
    {
        if ($scope === 'default') {
            if ("{$scopeId}" !== "0") {
                throw new InvalidArgumentException(sprintf("Invalid scope ID %d in scope '%s', must be 0", $scopeId, $scope));
            }
            return $scopeId;
        }
        if ($scope == 'websites' && !is_numeric($scopeId)) {
            $website = \Mage::app()->getWebsite($scopeId);
            if (!$website) {
                throw new InvalidArgumentException(sprintf("Invalid scope parameter, website '%s' does not exist.", $scopeId));
            }
            return $website->getId();
        }
        if ($scope == 'stores' && !is_numeric($scopeId)) {
            $store = \Mage::app()->getStore($scopeId);
            if (!$store) {
                throw new InvalidArgumentException(sprintf("Invalid scope parameter. store '%s' does not exist.", $scopeId));
            }
            return $store->getId();
        }
        $this->invalidScopeId($scopeId !== (string) (int) $scopeId, "Invalid scope parameter, %s is not an integer value", $scopeId);
        $this->invalidScopeId(0 - (bool) $allowZeroScope >= (int) $scopeId, "Invalid scope parameter, %s is not a positive integer value", $scopeId);
        return $scopeId;
    }