protected function findLighthouseScoreReportData(\SplFileInfo $path, array $selected)
    {
        $data = [];
        $json = json_decode(file_get_contents($path), true);

        foreach ($json['reportCategories'] as $report) {
            if (!isset($report['name']) || !isset($report['score'])) {
                continue;
            }
            $label = $report['name'];
            $key = Utility::cleanString(
                strtolower(strtr($label, ' ', '_')),
                '/[^a-zA-Z\_]/'
            );

            if (!in_array($key, $selected)) {
                continue;
            }

            $data[$key] = [
                'name' => $label,
                'score' => round($report['score'])
            ];
        }

        return $data;
    }
protected function findLighthouseScoreReportData(\SplFileInfo $path, array $selected)
    {
        $data = [];
        $json = json_decode(file_get_contents($path), true);

        foreach ($json['reportCategories'] as $report) {
            if (!isset($report['name']) || !isset($report['score'])) {
                continue;
            }
            $label = $report['name'];
            $key = Utility::cleanString(
                strtolower(strtr($label, ' ', '_')),
                '/[^a-zA-Z\_]/'
            );

            if (!in_array($key, $selected)) {
                continue;
            }

            $data[$key] = [
                'name' => $label,
                'score' => round($report['score'])
            ];
        }

        return $data;
    }
protected function findLighthouseScoreReportData ( \ SplFileInfo $ path , array $ selected ) { $ data = [ ] ; $ json = json_decode ( file_get_contents ( $ path ) , true ) ; foreach ( $ json [ 'reportCategories' ] as $ report ) { if ( ! isset ( $ report [ 'name' ] ) || ! isset ( $ report [ 'score' ] ) ) { continue ; } $ label = $ report [ 'name' ] ; $ key = Utility :: cleanString ( strtolower ( strtr ( $ label , ' ' , '_' ) ) , '/[^a-zA-Z\_]/' ) ; if ( ! in_array ( $ key , $ selected ) ) { continue ; } $ data [ $ key ] = [ 'name' => $ label , 'score' => round ( $ report [ 'score' ] ) ] ; } return $ data ; }
Find Google lighthouse score report data.

@param \SplFileInfo $path
The path the Google lighthouse report.
@param array $selected
An array of sections to retrieve scores for.

@return array
An array of section data with name, and scores.
Find Google lighthouse score report data .