*/ public function check_typed_address( mixed $typed_url ): array { $address = $this->usable_address( $typed_url ); if ( null === $address ) { $unusable = new Judgement( Reason::NoHost, null, null ); return $this->answer( $unusable ); } $judgement = $this->address_rules->is_internal( $address ) ? $this->internal_probe->judge( $address ) : $this->http_probe->judge( $address ); return $this->answer( $judgement ); } private function usable_address( mixed $typed_url ): string|null { if ( ! is_string( $typed_url ) ) { return null; } if ( ! $this->address_rules->is_usable_new_url( $typed_url ) ) { return null; } return $this->address_rules->normalize( $typed_url ); } /** @return array */ private function answer( Judgement $judgement ): array { return array( 'verdict' => $judgement->verdict()->value, 'reason' => $judgement->reason->value, 'http_code' => $judgement->http_code, 'final_url' => $judgement->final_url, ); } }