alexdebril/feed-io

View on GitHub

Showing 9 of 17 total issues

Feed has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Feed extends Node implements FeedInterface, ArrayableInterface, \JsonSerializable
{
    protected ArrayIterator $items;

    protected ArrayIterator $ns;
Severity: Minor
Found in src/FeedIo/Feed.php - About 2 hrs to fix

    Node has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Node implements NodeInterface, ElementsAwareInterface, ArrayableInterface
    {
        use ElementsAwareTrait;
    
        protected ArrayIterator $categories;
    Severity: Minor
    Found in src/FeedIo/Feed/Node.php - About 2 hrs to fix

      Function toArray has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function toArray(): array
          {
              $properties = get_object_vars($this);
              $properties['elements'] = iterator_to_array($this->getElementsGenerator());
              $properties['categories'] = iterator_to_array($this->getCategoriesGenerator());
      Severity: Minor
      Found in src/FeedIo/Feed/Node.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function extractFeeds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function extractFeeds(string $html, string $url = null): array    
          {
              $dom = new DOMDocument();
              $dom->loadHTML($html);
      
      
      Severity: Minor
      Found in src/FeedIo/Explorer.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function setHostInContent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function setHostInContent(string $host = null): void
          {
              if (property_exists($this, 'content')){
                  if (!is_null($host) && !is_null($this->content)) {
                      $this->content = preg_replace('!(<*\s*[^>]*)(href=)(.?)(\/[^\/])!','\1 href=\3'.$host.'\4', $this->content );
      Severity: Minor
      Found in src/FeedIo/Feed/Node.php - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              protected Document $document,
              protected FeedInterface $feed,
              protected DateTime $modifiedSince,
              protected ResponseInterface $response,
              protected string $url
      Severity: Minor
      Found in src/FeedIo/Reader/Result.php - About 35 mins to fix

        Function setProperty has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setProperty(NodeInterface $node, \DOMElement $element): void
            {
                if ($node instanceof FeedInterface) {
                    for ($i = $element->childNodes->length; --$i >= 0;) {
                        $child = $element->childNodes->item($i);
        Severity: Minor
        Found in src/FeedIo/Rule/Logo.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function filter(FeedInterface $feed): iterable
            {
                foreach ($feed as $item) {
                    foreach ($this->filters as $filter) {
                        if (!$filter->filter($item)) {
        Severity: Minor
        Found in src/FeedIo/Filter/Chain.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function addElementsFromNodeList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            private function addElementsFromNodeList(ElementsAwareInterface $node, ElementInterface $element, DOMNodeList $childNodeList): void
            {
                foreach ($childNodeList as $childNode) {
                    if ($childNode instanceof DOMText) {
                        continue;
        Severity: Minor
        Found in src/FeedIo/Rule/OptionalField.php - About 25 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language