field = $field; $this->sort = $sort; } public function isValid(): bool { return $this->field !== null && $this->sort !== null; } public static function fromBody(array $body): Sorting { return new Sorting( $body['field'] ?? null, $body['sort'] ?? null ); } }