Skip to content

Commit

Permalink
doc blocks for workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed May 19, 2016
1 parent 0df417a commit db83c69
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ class Workflow
{
protected $results = [];

/**
* Add a result to the workflow
*
* @return \Alfred\Workflows\Result
*/
public function result()
{
$result = new Result;
Expand All @@ -15,6 +20,14 @@ public function result()
return $result;
}

/**
* Sort the current results
*
* @param string $direction
* @param string $property
*
* @return \Alfred\Workflows\Workflow
*/
public function sortResults($direction = 'asc', $property = 'title')
{
usort($this->results, function ($a, $b) use ($direction, $property) {
Expand All @@ -28,6 +41,14 @@ public function sortResults($direction = 'asc', $property = 'title')
return $this;
}

/**
* Filter current results (destructive)
*
* @param string $query
* @param string $property
*
* @return \Alfred\Workflows\Workflow
*/
public function filterResults($query, $property = 'title')
{
if ($query === null || trim($query) === '') {
Expand All @@ -43,6 +64,11 @@ public function filterResults($query, $property = 'title')
return $this;
}

/**
* Output the results as JSON
*
* @return string
*/
public function output()
{
$output = [
Expand Down

0 comments on commit db83c69

Please sign in to comment.