src/CFDIReader/PostValidations/Validators/AbstractValidator.php
protected function sumNodes(SimpleXMLElement $collection = null, $attribute = '')
    {
        if (null === $collection) {
            return 0;
        }
        $sum = 0;
        if ('' === $attribute) {
            foreach ($collection as $node) {
                $sum = $sum + $this->value($node);
            }
        } else {
            foreach ($collection as $node) {
                $sum = $sum + $this->value($node[$attribute]);
            }
        }
        return $sum;
    }
protected function sumNodes(SimpleXMLElement $collection = null, $attribute = '')
    {
        if (null === $collection) {
            return 0;
        }
        $sum = 0;
        if ('' === $attribute) {
            foreach ($collection as $node) {
                $sum = $sum + $this->value($node);
            }
        } else {
            foreach ($collection as $node) {
                $sum = $sum + $this->value($node[$attribute]);
            }
        }
        return $sum;
    }
Compute the sum of a collection of nodes considering an attribute
@param SimpleXMLElement $collection
@param string $attribute
@return float