39 lines
919 B
PHP
39 lines
919 B
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
class OfferCoverage
|
|
{
|
|
public function __construct(private readonly ContentResolver $resolver) {}
|
|
|
|
/**
|
|
* @param list<LicenseArticle> $articles
|
|
* @return list<string>
|
|
*/
|
|
public function missingLeaves(CompositionVersion $version, array $articles): array
|
|
{
|
|
$covered = [];
|
|
|
|
foreach ($articles as $article) {
|
|
$release = $article->currentRelease;
|
|
if ($release === null) {
|
|
continue;
|
|
}
|
|
|
|
foreach ($release->contents()->pluck('content_element_version_id') as $id) {
|
|
$covered[(int) $id] = true;
|
|
}
|
|
}
|
|
|
|
$missing = [];
|
|
|
|
foreach ($this->resolver->expand($version) as $row) {
|
|
if (! isset($covered[$row['version_id']])) {
|
|
$missing[] = $row['path'];
|
|
}
|
|
}
|
|
|
|
return $missing;
|
|
}
|
|
}
|