$data */ public static function fromArray(array $data): self { foreach (self::requiredKeys() as $key) { if (! array_key_exists($key, $data)) { throw new InvalidArgumentException(sprintf('Canonical control artifact suitability is missing [%s].', $key)); } } return new self( baseline: (bool) $data['baseline'], drift: (bool) $data['drift'], finding: (bool) $data['finding'], exception: (bool) $data['exception'], evidence: (bool) $data['evidence'], review: (bool) $data['review'], report: (bool) $data['report'], ); } /** * @return array{baseline: bool, drift: bool, finding: bool, exception: bool, evidence: bool, review: bool, report: bool} */ public function toArray(): array { return [ 'baseline' => $this->baseline, 'drift' => $this->drift, 'finding' => $this->finding, 'exception' => $this->exception, 'evidence' => $this->evidence, 'review' => $this->review, 'report' => $this->report, ]; } /** * @return list */ public static function requiredKeys(): array { return ['baseline', 'drift', 'finding', 'exception', 'evidence', 'review', 'report']; } }