grgk/seo-analyzer

View on GitHub
src/Parser/ExampleCustomParser.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace SeoAnalyzer\Parser;

class ExampleCustomParser extends Parser
{
    /**
     * @inheritDoc
     */
    public function getAlts(): array
    {
        $alts = [];
        if ($this->getDomElements('img')->length > 0) {
            foreach ($this->getDomElements('img') as $img) {
                $alts[] = [
                    'alt' => trim($img->getAttribute('alt')),
                    'src' => trim($img->getAttribute('src')),
                ];
            }
        }
        return $alts;
    }
}