Get the granularity.

@return \cogpowered\FineDiff\Granularity\Granularity

@throws \InvalidArgumentException
176051
protected function granularity()
    {
        $granularity = $this->config('diff.granularity', $this->activity->model_type);

        switch ($granularity) {
            case 'character':
                return new \cogpowered\FineDiff\Granularity\Character;
            case 'word':
                return new \cogpowered\FineDiff\Granularity\Word;
            case 'sentence':
                return new \cogpowered\FineDiff\Granularity\Sentence;
            case 'paragraph':
                return new \cogpowered\FineDiff\Granularity\Paragraph;
        }

        throw new InvalidArgumentException("The '$granularity' granularity is not valid.");
    }
190862
protected function get()
    {
        if ($this->model instanceof LengthAwarePaginator) {
            return $this->model;
        }

        if ($this->relation) {
            $this->model = $this->relation->getQuery();
        }

        $this->setSort();
        $this->setPaginate();

        $this->queries->unique()->each(function ($query) {
            $this->model = call_user_func_array([$this->model, $query['method']], $query['arguments']);
        });

        if ($this->model instanceof Collection) {
            return $this->model;
        }

        if ($this->model instanceof LengthAwarePaginator) {
            $this->handleInvalidPage($this->model);

            return $this->model->getCollection();
        }

        throw new \Exception('Grid query error');
    }
1209594
public function createNew()
    {
        $resource = $this->traitCreateNew();

        if (!$resource instanceof TranslatableInterface) {
            throw new \InvalidArgumentException('Resource must implement TranslatableInterface.');
        }

        $resource->setCurrentLocale($this->localeProvider->getCurrentLocale());
        $resource->setFallbackLocale($this->localeProvider->getFallbackLocale());

        return $resource;
    }
1036028
public function getAdapterInstance()
    {
        if ($this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) {
            return $this->adapter;
        }

        $adapter = $this->adapter;
        $options = $this->getOptions();
        if (! class_exists($adapter)) {
            $adapter = __CLASS__ . '\\' . ucfirst($adapter);
            if (! class_exists($adapter)) {
                throw new Exception\RuntimeException(sprintf(
                    '%s unable to load adapter; class "%s" not found',
                    __METHOD__,
                    $this->adapter
                ));
            }
        }

        $this->adapter = new $adapter($options);
        if (! $this->adapter instanceof Encrypt\EncryptionAlgorithmInterface) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Encryption adapter "%s" does not implement %s\\EncryptionAlgorithmInterface',
                $adapter,
                __CLASS__
            ));
        }
        return $this->adapter;
    }
1212243
public function getPriority()
    {
        if (!isset($this->priority)) {
            $typeToPriority = array(static::CONTEXT_ERROR   => static::PRIORITY_MAX,
                                    static::CONTEXT_WARNING => static::PRIORITY_HIGH,
                                    static::CONTEXT_SUCCESS => static::PRIORITY_MIN,
                                    static::CONTEXT_INFO    => static::PRIORITY_LOW);

            if (array_key_exists($this->context, $typeToPriority)) {
                return $typeToPriority[$this->context];
            }

            return static::PRIORITY_LOW;
        }

        return $this->priority;
    }
648269
public Granularity getGranularity() {
        Interval interval = getInterval();
        if (interval != null) {
            return interval.getStartGranularity();
        } else {
            return null;
        }
    }
1087958
public function getEtag()
    {
        if ( $this->etag === false ) {
            $this->etag = $this->generateEtag();
        }

        return $this->etag;
    }
1139326
public static function getInstance()
    {
        $accesor = static::getAccessor();

        if (!static::$instance instanceof $accesor) {
            static::beforeConstruct();

            $args = static::getArguments();

            static::$instance = static::make($accesor, $args);

            static::afterConstruct();
        }

        return static::$instance;
    }
21346
protected function getClassParameter()
    {
        $class = parent::getClassParameter();
        $rootUserClass = $this->getClass(GenerisRdf::CLASS_GENERIS_USER);

        if ($class->getUri() == $rootUserClass->getUri()) {
            return $class;
        }

        /** @var core_kernel_classes_Class $instance */
        foreach ($rootUserClass->getSubClasses(true) as $instance) {
            if ($instance->getUri() == $class->getUri()) {
                return $class;
            }
        }

        throw new InvalidArgumentException('Only user classes are allowed as classUri.');
    }
1235900
protected function getResourceParameter()
    {
        $resource = parent::getResourceParameter();
        if ($resource->isInstanceOf($this->getClass(GenerisRdf::CLASS_GENERIS_USER))) {
            return $resource;
        }

        throw new InvalidArgumentException('Only user resource are allowed.');
    }
208888
public function getDataSource()
    {
        $this->dataSource->bindCellsset($this->getCells());

        if (null != $this->getDefaultOrderDirection() && null != $this->getDefaultOrderField() && ($this->dataSource instanceof \DataGrid\DataSource\DataSourceSortableInterface)) {
            $this->dataSource->addOrderBy($this->getDefaultOrderField(), $this->getDefaultOrderDirection());
        }

        if ($this->hasFilter()) {
            $this->getFilter()->applyTo($this->dataSource);
        }

        if (null != $this->getPaginator()) {
            $this->getPaginator()->applyTo($this->dataSource);
        }
        return $this->dataSource;
    }
1147578
public function base()
    {
        if (!$this->validate()) {
            throw new \InvalidArgumentException("Invalid URI: $this->uri");
        }
        $parts = [
            'scheme' => parse_url($this->uri, PHP_URL_SCHEME),
            'host' => parse_url($this->uri, PHP_URL_HOST),
        ];
        $parts['port'] = is_int($port = parse_url($this->uri, PHP_URL_PORT)) ? $port : getservbyname($parts['scheme'], 'tcp');
        return strtolower($parts['scheme'] . '://' . $parts['host'] . ':' . $parts['port']);
    }
346004
public function get()
    {
        if ($this->argument instanceof Argument && ! $this->argument->has('color')) {
            return $this->text;
        }

        $text = '';
        if ($this->foregroundColor !== '') {

            //~ Highlight
            $highlight = $this->hasHighlightedForeground ? static::HIGH_FOREGROUND : static::REGULAR_FOREGROUND;

            //~ Decoration
            $decoration = $this->isBold ? static::DECORATION_BOLD : '';
            $decoration .= $this->isUnderline ? static::DECORATION_UNDERLINE : '';
            $decoration = ! empty($decoration) ? $decoration : static::DECORATION_NONE;

            //~ Apply style
            $text .= self::BEGIN . $decoration . $highlight . $this->foregroundColor . self::END;
        }

        if ($this->backgroundColor !== '') {
            $highlight = $this->hasHighlightedBackground ? static::HIGH_BACKGROUND : static::REGULAR_BACKGROUND;
            $text .= self::BEGIN . $highlight . $this->backgroundColor . self::END;
        }

        $text .= $this->text . self::DESACTIVATE;

        return $text;
    }
672455
public function fetch()
    {
        $ret = array();
        $pos = 0;
        $len = count($this->_arguments);

        foreach ($this->_descriptors as $name => $descriptor) {
            $value = $descriptor->getDefault();

            for ($i = $pos; ; $i++) {
                if ($i < $len && $descriptor->match($this->_arguments[$i])) {
                    $value = $this->_arguments[$i];
                    $pos = $i + 1;
                    break;
                } else {
                    if ($descriptor->isRequired()) {
                        throw new InvalidArgumentException(
                            "Argument is required: `$name`"
                        );
                    }
                    if ($i > $len - 1) {
                        break;
                    }
                }
            }

            $ret[$name] = $value;
        }

        return $ret;
    }
1127310
public function toPayload()
    {
        if (empty($this->method) || !is_string($this->method)) {
            throw new InvalidArgumentException('Please check the method set properly.');
        }
        if (empty($this->id)) {
            $id = rand();
        } else {
            $id = $this->id;
        }
        $rpc = [
            'id' => $id,
            'jsonrpc' => $this->rpcVersion,
            'method' => $this->method
        ];

        if (count($this->arguments) > 0) {
            $rpc['params'] = $this->arguments;
        }
        return $rpc;
    }
591749
public function getVersion() : ?int
    {
        if (null === $this->version) {
            $success = null;

            try {
                $version = $this->getItem('browscap.version', false, $success);
            } catch (InvalidArgumentException $e) {
                $this->logger->error(new \InvalidArgumentException('an error occured while reading the data version from the cache', 0, $e));
                $version = null;
            }

            if (null !== $version && $success) {
                $this->version = (int) $version;
            }
        }

        return $this->version;
    }
925634
public function getParentAssociationMapping()
    {
        // NEXT_MAJOR: remove array check
        if (\is_array($this->parentAssociationMapping) && $this->getParent()) {
            $parent = $this->getParent()->getCode();

            if (\array_key_exists($parent, $this->parentAssociationMapping)) {
                return $this->parentAssociationMapping[$parent];
            }

            throw new \InvalidArgumentException(sprintf(
                "There's no association between %s and %s.",
                $this->getCode(),
                $this->getParent()->getCode()
            ));
        }

        // NEXT_MAJOR: remove this line
        return $this->parentAssociationMapping;
    }