feat: add url mapping value objects

This commit is contained in:
Keith Solomon
2026-04-26 14:29:53 -05:00
parent 3c254a34c9
commit 8d7abc8536
3 changed files with 100 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace WPContentSync\Url;
final class UrlMappingCollection {
/**
* @var array<int, UrlMapping>
*/
private array $mappings;
/**
* @param array<int, UrlMapping> $mappings URL mappings.
*/
public function __construct( array $mappings ) {
foreach ( $mappings as $mapping ) {
if ( ! $mapping instanceof UrlMapping ) {
throw new \InvalidArgumentException( 'URL mapping collections only accept UrlMapping instances.' );
}
}
$this->mappings = array_values( $mappings );
}
/**
* @return array<int, UrlMapping>
*/
public function all(): array {
return $this->mappings;
}
}