<?php
/**
 * Normalized object presented to detectors.
 *
 * @package LocalGuardScanner
 */

namespace LocalGuardScanner\Domain\Detection;

use InvalidArgumentException;

/**
 * Immutable description of a file or database value.
 */
final class ScannableObject {
	/** @var string */
	private $type;
	/** @var string */
	private $locator;
	/** @var array<string,mixed> */
	private $attributes;

	/**
	 * @param string              $type       Object type.
	 * @param string              $locator    Stable locator.
	 * @param array<string,mixed> $attributes Safe attributes.
	 */
	public function __construct( $type, $locator, array $attributes = array() ) {
		if ( '' === trim( $type ) || '' === trim( $locator ) ) {
			throw new InvalidArgumentException( 'Scannable objects require type and locator.' );
		}
		$this->type       = $type;
		$this->locator    = $locator;
		$this->attributes = $attributes;
	}

	/** @return string */
	public function type() {
		return $this->type;
	}

	/** @return string */
	public function locator() {
		return $this->locator;
	}

	/** @return array<string,mixed> */
	public function attributes() {
		return $this->attributes;
	}
}
