From 8a69be46ed1cb3f70274961c130fc8c21488d3bd Mon Sep 17 00:00:00 2001 From: Alexandre Mercier Date: Fri, 9 Aug 2013 15:20:37 +0200 Subject: [PATCH] Added Job usage Documentation --- docs/api-job.md | 25 +++++++++++++++++++++++++ src/Cli/Helpers/Job.php | 26 ++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docs/api-job.md diff --git a/docs/api-job.md b/docs/api-job.md new file mode 100644 index 0000000..945eef7 --- /dev/null +++ b/docs/api-job.md @@ -0,0 +1,25 @@ +\Cli\Helpers\Job +================ + +Usage +----- + +On successful jobs: +```php +\Cli\Helpers\Job::run('Doing awesome stuff', function() { + ... // awesome stuff +}); +``` +``` +Doing awesome stuff... OK +``` + +On unsuccessful jobs: +```php +\Cli\Helpers\Job::run('Fighting Chuck Norris', function() { + ... // throws a RoundHouseKickException('You've received a round-house kick', 'face') +}); +``` +``` +Fighting Chuck Norris... NOK - You've received a round-house kick in the face +``` diff --git a/src/Cli/Helpers/Job.php b/src/Cli/Helpers/Job.php index 09c04f0..2480b90 100644 --- a/src/Cli/Helpers/Job.php +++ b/src/Cli/Helpers/Job.php @@ -2,6 +2,32 @@ namespace Cli\Helpers; +/** + * Utility class to run a job and catch exceptions. + * + * Usage + * ----- + * + * On successful jobs: + * ```php + * \Cli\Helpers\Job::run('Doing awesome stuff', function() { + * ... // awesome stuff + * }); + * ``` + * ``` + * Doing awesome stuff... OK + * ``` + * + * On unsuccessful jobs: + * ```php + * \Cli\Helpers\Job::run('Fighting Chuck Norris', function() { + * ... // throws a RoundHouseKickException('You've received a round-house kick', 'face') + * }); + * ``` + * ``` + * Fighting Chuck Norris... NOK - You've received a round-house kick in the face + * ``` + */ class Job { protected $message;