PhpCsFixer\Fixer\Comment\HeaderCommentFixer::parseConfiguration PHP Method

parseConfiguration() private method

private parseConfiguration ( array $configuration = null ) : array
$configuration array
return array
    private function parseConfiguration(array $configuration = null)
    {
        if (null === $configuration || !array_key_exists('header', $configuration)) {
            throw new RequiredFixerConfigurationException($this->getName(), 'Configuration is required.');
        }
        $header = $configuration['header'];
        if (!is_string($header)) {
            throw new InvalidFixerConfigurationException($this->getName(), sprintf('Header configuration is invalid. Expected "string", got "%s".', is_object($header) ? get_class($header) : gettype($header)));
        }
        if (array_key_exists('commentType', $configuration)) {
            $commentType = $configuration['commentType'];
            if (!in_array($commentType, array(self::HEADER_PHPDOC, self::HEADER_COMMENT), true)) {
                throw new InvalidFixerConfigurationException($this->getName(), sprintf('Header type configuration is invalid, expected "PHPDoc" or "comment", got "%s".', is_object($commentType) ? get_class($commentType) : var_export($commentType, true)));
            }
        } else {
            $commentType = self::HEADER_COMMENT;
        }
        $header = '' === trim($header) ? '' : $this->encloseTextInComment($header, $commentType);
        if (array_key_exists('location', $configuration)) {
            $location = $configuration['location'];
            switch ($location) {
                case 'after_open':
                    $location = self::HEADER_LOCATION_AFTER_OPEN;
                    break;
                case 'after_declare_strict':
                    $location = self::HEADER_LOCATION_AFTER_DECLARE_STRICT;
                    break;
                default:
                    throw new InvalidFixerConfigurationException($this->getName(), sprintf('Header location configuration is invalid, expected "after_open" or "after_declare_strict", got "%s".', is_object($location) ? get_class($location) : var_export($location, true)));
            }
        } else {
            $location = self::HEADER_LOCATION_AFTER_DECLARE_STRICT;
        }
        if (array_key_exists('separate', $configuration)) {
            $headerLineSeparation = $configuration['separate'];
            switch ($headerLineSeparation) {
                case 'both':
                    $headerLineSeparation = self::HEADER_LINE_SEPARATION_BOTH;
                    break;
                case 'top':
                    $headerLineSeparation = self::HEADER_LINE_SEPARATION_TOP;
                    break;
                case 'bottom':
                    $headerLineSeparation = self::HEADER_LINE_SEPARATION_BOTTOM;
                    break;
                case 'none':
                    $headerLineSeparation = self::HEADER_LINE_SEPARATION_NONE;
                    break;
                default:
                    throw new InvalidFixerConfigurationException($this->getName(), sprintf('Header separate configuration is invalid, expected "both", "top", "bottom" or "none", got "%s".', is_object($headerLineSeparation) ? get_class($headerLineSeparation) : var_export($headerLineSeparation, true)));
            }
        } else {
            $headerLineSeparation = self::HEADER_LINE_SEPARATION_BOTH;
        }
        return array($header, $commentType, $location, $headerLineSeparation);
    }