notEmpty()) ->key('theme', v::optional(v::stringType()), true); try { $validator->assert($data); } catch (NestedValidationException $e) { throw new InvalidArgumentException('CKBox config validation failed: ' . implode(', ', $e->getMessages())); } return new CKBox( version: (string) $data['version'], theme: isset($data['theme']) ? (string) $data['theme'] : null, ); } /** * Dump CKBox instance to an array compatible with CKBoxParser::parse(). * * @param CKBox $ckbox * @return array */ public static function dump(CKBox $ckbox): array { $result = ['version' => $ckbox->version]; if ($ckbox->theme !== null) { $result['theme'] = $ckbox->theme; } return $result; } }