0 ? Services::course_repo()->get( $course_id ) : null; if ( null === $course || $course->home_post_id <= 0 || null === get_post( $course->home_post_id ) ) { return self::NOT_FOUND; } if ( user_can( $user_id, 'edit_post', $course->home_post_id ) ) { return self::OK; } return Services::gate()->can_view_course( $user_id, $course_id )->allowed ? self::FORBIDDEN : self::NOT_FOUND; } public static function course( int $course_id, int $user_id ): ?Course { return self::OK === self::check( $course_id, $user_id ) ? Services::course_repo()->get( $course_id ) : null; } public static function rest( string $decision ) { switch ( $decision ) { case self::OK: return true; case self::NOT_LOGGED_IN: return Errors::not_logged_in(); case self::FORBIDDEN: return Errors::forbidden(); default: return Errors::not_found(); } } }