/** * @param array $types * * @throws \InvalidArgumentException * * @return static */ public function withTypes(array $types) { $choices = [PlatformInterface::TYPE_MOBILE, PlatformInterface::TYPE_TV, PlatformInterface::TYPE_WEB]; Assertion::allChoice($types, $choices); Assertion::same($types, array_unique($types)); $instance = clone $this; $instance->types = $types; return $instance; }
/** * @param array $genres * * @throws \InvalidArgumentException * * @return static */ public function withGenres(array $genres) { $choices = [NewsInterface::GENRE_BLOG, NewsInterface::GENRE_OP_ED, NewsInterface::GENRE_OPINION, NewsInterface::GENRE_SATIRE, NewsInterface::GENRE_USER_GENERATED]; Assertion::allChoice($genres, $choices); Assertion::same($genres, array_unique($genres)); $instance = clone $this; $instance->genres = $genres; return $instance; }