value = self::normalize( $value ); } /** * Create a profile from a string. * * @param string $value Profile value. */ public static function from_string( string $value ): self { return new self( $value ); } /** * Create the default free profile. */ public static function free(): self { return new self( self::FREE ); } /** * Normalize an arbitrary profile string. * * @param string $value Profile value. */ public static function normalize( string $value ): string { $value = strtolower( trim( $value ) ); return self::is_valid( $value ) ? $value : self::FREE; } /** * Whether a profile value is supported. * * @param string $value Profile value. */ public static function is_valid( string $value ): bool { return in_array( $value, self::get_supported_profiles(), true ); } /** * Get supported profile values. * * @return array */ public static function get_supported_profiles(): array { return array( self::FREE, self::PRO_FREEMIUS, self::PRO_CODECANYON, self::DEVELOPMENT, ); } /** * Get the normalized profile value. */ public function get_value(): string { return $this->value; } /** * Whether this profile is the free build. */ public function is_free(): bool { return self::FREE === $this->value; } /** * Whether this profile may prepare commercial boundaries. */ public function allows_commercial_boundary(): bool { return ! $this->is_free(); } }