Add missing documentation

This commit is contained in:
Justin Foell
2019-02-01 14:17:22 -06:00
parent 629d8c3c59
commit 9813dc2aec
6 changed files with 41 additions and 24 deletions
+4 -5
View File
@@ -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 <justin@foell.org>
*/
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 <justin@foell.org>
* @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 <justin@foell.org>
*/
public function get_activities_longer_than( $activities, $dist ) {
$som = WPStrava_SOM::get_som();
+1 -1
View File
@@ -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 <mail@sebastianerb.com>
* @author Sebastian Erb <mail@sebastianerb.com>
* @since NEXT
*/
public static function get_type_group( $type ) {
+24 -2
View File
@@ -38,18 +38,32 @@ class WPStrava_Exception extends WPStrava_Abstract_Exception {
*
* @param WP_Error $error
* @return WPStrava_Exception
* @author Justin Foell <justin.foell@webdevstudios.com>
* @since
* @author Justin Foell <justin@foell.org>
* @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 <pre> tags.
* @author Justin Foell <justin@foell.org>
* @since 1.6.0
*/
public function to_html() {
return '<pre>' . $this . '</pre>';
}
/**
* Magic method to convert this exception to a string.
*
* @return string
* @author Justin Foell <justin@foell.org>
* @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 <justin@foell.org>
* @since 1.6.0
*/
public function get_formatted_message( $exception ) {
$code = $exception->getCode();
+5 -9
View File
@@ -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 <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @since 1.2.0
*
* @param string $id Athlete Token or Club ID.
* @param object $activity stdClass Strava activity object.
*/
+1 -1
View File
@@ -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 <justin@foell.org>
*/
public static function get_som( $som = null ) {
$som = $som ? $som : WPStrava::get_instance()->settings->som;
+6 -6
View File
@@ -357,7 +357,7 @@ class WPStrava_Settings {
* Gets all saved strava tokens as an array.
*
* @return array
* @author Justin Foell
* @author Justin Foell <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @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 <justin@foell.org>
* @since 1.2.0
*/
public function add_token( $token ) {