private function calculatePropertiesToBeApplied(array $properties, array $cssProperties)
    {
        if (empty($properties)) {
            return $cssProperties;
        }

        foreach ($properties as $property) {
            if (isset($cssProperties[$property->getName()])) {
                $existingProperty = $cssProperties[$property->getName()];

                //skip check to overrule if existing property is important and current is not
                if ($existingProperty->isImportant() && !$property->isImportant()) {
                    continue;
                }

                //overrule if current property is important and existing is not, else check specificity
                $overrule = !$existingProperty->isImportant() && $property->isImportant();
                if (!$overrule) {
                    $overrule = $existingProperty->getOriginalSpecificity()->compareTo($property->getOriginalSpecificity()) <= 0;
                }

                if ($overrule) {
                    unset($cssProperties[$property->getName()]);
                    $cssProperties[$property->getName()] = $property;
                }
            } else {
                $cssProperties[$property->getName()] = $property;
            }
        }

        return $cssProperties;
    }
private function calculatePropertiesToBeApplied(array $properties, array $cssProperties)
    {
        if (empty($properties)) {
            return $cssProperties;
        }

        foreach ($properties as $property) {
            if (isset($cssProperties[$property->getName()])) {
                $existingProperty = $cssProperties[$property->getName()];

                //skip check to overrule if existing property is important and current is not
                if ($existingProperty->isImportant() && !$property->isImportant()) {
                    continue;
                }

                //overrule if current property is important and existing is not, else check specificity
                $overrule = !$existingProperty->isImportant() && $property->isImportant();
                if (!$overrule) {
                    $overrule = $existingProperty->getOriginalSpecificity()->compareTo($property->getOriginalSpecificity()) <= 0;
                }

                if ($overrule) {
                    unset($cssProperties[$property->getName()]);
                    $cssProperties[$property->getName()] = $property;
                }
            } else {
                $cssProperties[$property->getName()] = $property;
            }
        }

        return $cssProperties;
    }
private function calculatePropertiesToBeApplied ( array $ properties , array $ cssProperties ) { if ( empty ( $ properties ) ) { return $ cssProperties ; } foreach ( $ properties as $ property ) { if ( isset ( $ cssProperties [ $ property -> getName ( ) ] ) ) { $ existingProperty = $ cssProperties [ $ property -> getName ( ) ] ; //skip check to overrule if existing property is important and current is not if ( $ existingProperty -> isImportant ( ) && ! $ property -> isImportant ( ) ) { continue ; } //overrule if current property is important and existing is not, else check specificity $ overrule = ! $ existingProperty -> isImportant ( ) && $ property -> isImportant ( ) ; if ( ! $ overrule ) { $ overrule = $ existingProperty -> getOriginalSpecificity ( ) -> compareTo ( $ property -> getOriginalSpecificity ( ) ) <= 0 ; } if ( $ overrule ) { unset ( $ cssProperties [ $ property -> getName ( ) ] ) ; $ cssProperties [ $ property -> getName ( ) ] = $ property ; } } else { $ cssProperties [ $ property -> getName ( ) ] = $ property ; } } return $ cssProperties ; }
Merge the CSS rules to determine the applied properties.

@param Css\Property\Property[] $properties
@param Css\Property\Property[] $cssProperties existing applied properties indexed by name

@return Css\Property\Property[] updated properties, indexed by name
Merge the CSS rules to determine the applied properties .