From 9813dc2aec5424ea6d6f42a466b98850f67da628 Mon Sep 17 00:00:00 2001 From: Justin Foell Date: Fri, 1 Feb 2019 14:17:22 -0600 Subject: [PATCH] Add missing documentation --- lib/WPStrava/Activity.php | 9 ++++----- lib/WPStrava/ActivityType.php | 2 +- lib/WPStrava/Exception.php | 26 ++++++++++++++++++++++++-- lib/WPStrava/LatestMapWidget.php | 14 +++++--------- lib/WPStrava/SOM.php | 2 +- lib/WPStrava/Settings.php | 12 ++++++------ 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/lib/WPStrava/Activity.php b/lib/WPStrava/Activity.php index 68769e0..9572dc3 100755 --- a/lib/WPStrava/Activity.php +++ b/lib/WPStrava/Activity.php @@ -13,7 +13,7 @@ class WPStrava_Activity { * @param string $athlete_token Token of athlete to retrieve for * @param int $activity_id ID of activity to retrieve. * @return object stdClass representing this activity. - * @author Justin Foell + * @author Justin Foell */ public function get_activity( $athlete_token, $activity_id ) { return WPStrava::get_instance()->get_api( $athlete_token )->get( "activities/{$activity_id}" ); @@ -22,8 +22,7 @@ class WPStrava_Activity { /** * Get activity list from Strava API. * - * @author Justin Foell - * + * @author Justin Foell * @param string $athlete_token Token of athlete to retrieve for * @param int $club_id Club ID of all club riders (optional). * @param int|null $quantity Number of records to retrieve (optional). @@ -52,12 +51,12 @@ class WPStrava_Activity { } /** - * Undocumented function + * Get activities with a distance longer than specified length. * * @param array $activities * @param float $dist Distance in default system of measure (km/mi). * @return void - * @author Justin Foell + * @author Justin Foell */ public function get_activities_longer_than( $activities, $dist ) { $som = WPStrava_SOM::get_som(); diff --git a/lib/WPStrava/ActivityType.php b/lib/WPStrava/ActivityType.php index c404b15..40ead7d 100644 --- a/lib/WPStrava/ActivityType.php +++ b/lib/WPStrava/ActivityType.php @@ -61,7 +61,7 @@ class WPStrava_ActivityType { * * @param string $type Type provided by Strava. * @return string Type group (water/pace/speed/other). - * @author @author Sebastian Erb + * @author Sebastian Erb * @since NEXT */ public static function get_type_group( $type ) { diff --git a/lib/WPStrava/Exception.php b/lib/WPStrava/Exception.php index b7e9afa..325c4e4 100644 --- a/lib/WPStrava/Exception.php +++ b/lib/WPStrava/Exception.php @@ -38,18 +38,32 @@ class WPStrava_Exception extends WPStrava_Abstract_Exception { * * @param WP_Error $error * @return WPStrava_Exception - * @author Justin Foell - * @since + * @author Justin Foell + * @since 1.6.0 */ public static function from_wp_error( WP_Error $error ) { $class = __CLASS__; return new $class( $error->get_error_message( $error->get_error_code() ) ); } + /** + * HTML version of this exception. + * + * @return string The exception string wrapped in
 tags.
+	 * @author Justin Foell 
+	 * @since  1.6.0
+	 */
 	public function to_html() {
 		return '
' . $this . '
'; } + /** + * Magic method to convert this exception to a string. + * + * @return string + * @author Justin Foell + * @since 1.6.0 + */ public function __toString() { if ( WPSTRAVA_DEBUG && $this->getPrevious() ) { return $this->get_formatted_message( $this->getPrevious() ); @@ -58,6 +72,14 @@ class WPStrava_Exception extends WPStrava_Abstract_Exception { return $this->get_formatted_message( $this ); } + /** + * Exception message with extra formatting. + * + * @param Exception $exception + * @return string Formatted exception message. + * @author Justin Foell + * @since 1.6.0 + */ public function get_formatted_message( $exception ) { $code = $exception->getCode(); diff --git a/lib/WPStrava/LatestMapWidget.php b/lib/WPStrava/LatestMapWidget.php index 0ca26f7..1eef15d 100644 --- a/lib/WPStrava/LatestMapWidget.php +++ b/lib/WPStrava/LatestMapWidget.php @@ -96,7 +96,7 @@ class WPStrava_LatestMapWidget extends WP_Widget { try { $activities = $strava_activity->get_activities( $athlete_token, $strava_club_id ); - } catch( WPStrava_Exception $e ) { + } catch ( WPStrava_Exception $e ) { echo $e->to_html(); } @@ -136,8 +136,7 @@ class WPStrava_LatestMapWidget extends WP_Widget { /** * Get image for specific activity using Static Maps class. * - * @author Justin Foell - * + * @author Justin Foell * @param string $id Athlete Token or Club ID. * @param object $activity Activity to get image for. * @param boolean $build_new Whether to refresh the image from cache. @@ -157,9 +156,8 @@ class WPStrava_LatestMapWidget extends WP_Widget { /** * Update map in option to cache. * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 - * * @param string $id Athlete Token or Club ID. * @param string $img Image tag. */ @@ -170,9 +168,8 @@ class WPStrava_LatestMapWidget extends WP_Widget { /** * Update activity in option to cache. * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 - * * @param string $id Athlete Token or Club ID. * @param object $activity stdClass Strava activity object. */ @@ -183,9 +180,8 @@ class WPStrava_LatestMapWidget extends WP_Widget { /** * Update activity in transient to cache. * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 - * * @param string $id Athlete Token or Club ID. * @param object $activity stdClass Strava activity object. */ diff --git a/lib/WPStrava/SOM.php b/lib/WPStrava/SOM.php index e47a605..7730606 100644 --- a/lib/WPStrava/SOM.php +++ b/lib/WPStrava/SOM.php @@ -8,7 +8,7 @@ abstract class WPStrava_SOM { * * @param string $som 'english' or 'metric' * @return WPStrava_SOM Instance of SOM - * @author Justin Foell + * @author Justin Foell */ public static function get_som( $som = null ) { $som = $som ? $som : WPStrava::get_instance()->settings->som; diff --git a/lib/WPStrava/Settings.php b/lib/WPStrava/Settings.php index 38c2c76..e6acd32 100644 --- a/lib/WPStrava/Settings.php +++ b/lib/WPStrava/Settings.php @@ -357,7 +357,7 @@ class WPStrava_Settings { * Gets all saved strava tokens as an array. * * @return array - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 */ public function get_tokens() { @@ -379,7 +379,7 @@ class WPStrava_Settings { * Returns first (default) token saved. * * @return string|null - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 */ public function get_default_token() { @@ -391,7 +391,7 @@ class WPStrava_Settings { * Get all tokens and their nicknames in one array. * * @return void - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 */ public function get_all_tokens() { @@ -413,7 +413,7 @@ class WPStrava_Settings { /** * Returns default nickname 'Default' / 'Athlete n'. * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 * * @param integer $number Athlete number (default 1). @@ -427,7 +427,7 @@ class WPStrava_Settings { /** * Checks for valid tokens. * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 * * @param string|array Single token or array of tokens. @@ -454,7 +454,7 @@ class WPStrava_Settings { * * @param string $token * - * @author Justin Foell + * @author Justin Foell * @since 1.2.0 */ public function add_token( $token ) {