Skip to content

Commit

Permalink
doc blocks for result
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed May 19, 2016
1 parent db83c69 commit 2fef46b
Showing 1 changed file with 96 additions and 7 deletions.
103 changes: 96 additions & 7 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,24 @@ class Result

protected $mods = [];

public function generateUid($str)
{
$this->uid = md5($str);

return $this;
}

/**
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setValid($valid = true)
{
$this->valid = !!$valid;

return $this;
}

/**
* @param string $type (deafult|file|file:skipcheck)
* @param bool $verify_existence When used with $type 'file'
*
* @return \Alfred\Workflows\Result
*/
protected function setType($type, $verify_existence = true)
{
if (in_array($type, ['default', 'file', 'file:skipcheck'])) {
Expand All @@ -55,6 +59,12 @@ protected function setType($type, $verify_existence = true)
return $this;
}

/**
* @param string $path
* @param string|null $type (fileicon|filetype)
*
* @return \Alfred\Workflows\Result
*/
protected function setIcon($path, $type = null)
{
$this->icon = [
Expand All @@ -68,23 +78,44 @@ protected function setIcon($path, $type = null)
return $this;
}

/**
* @param string $path
*
* @return \Alfred\Workflows\Result
*/
protected function setFileiconIcon($path)
{
return $this->setIcon($path, 'fileicon');
}

/**
* @param string $path
*
* @return \Alfred\Workflows\Result
*/
protected function setFiletypeIcon($path)
{
return $this->setIcon($path, 'filetype');
}

/**
* @param string $subtitle
*
* @return \Alfred\Workflows\Result
*/
protected function setSubtitle($subtitle)
{
$this->subtitle = $subtitle;

return $this;
}

/**
* @param string $type (copy|largetype)
* @param string $text
*
* @return \Alfred\Workflows\Result
*/
protected function setText($type, $text)
{
if (!in_array($type, ['copy', 'largetype'])) {
Expand All @@ -96,16 +127,34 @@ protected function setText($type, $text)
return $this;
}

/**
* @param string $copy
*
* @return \Alfred\Workflows\Result
*/
protected function setCopy($copy)
{
return $this->setText('copy', $copy);
}

/**
* @param string $largetype
*
* @return \Alfred\Workflows\Result
*/
protected function setLargetype($largetype)
{
return $this->setText('largetype', $largetype);
}

/**
* @param string $mod (shift|fn|ctrl|alt|cmd)
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setMod($mod, $subtitle, $arg, $valid = true)
{
if (!in_array($mod, ['shift', 'fn', 'ctrl', 'alt', 'cmd'])) {
Expand All @@ -117,31 +166,71 @@ protected function setMod($mod, $subtitle, $arg, $valid = true)
return $this;
}

/**
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setCmd($subtitle, $arg, $valid = true)
{
return $this->setMod('cmd', $subtitle, $arg, $valid);
}

/**
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setShift($subtitle, $arg, $valid = true)
{
return $this->setMod('shift', $subtitle, $arg, $valid);
}

/**
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setFn($subtitle, $arg, $valid = true)
{
return $this->setMod('fn', $subtitle, $arg, $valid);
}

/**
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setCtrl($subtitle, $arg, $valid = true)
{
return $this->setMod('ctrl', $subtitle, $arg, $valid);
}

/**
* @param string $subtitle
* @param string $arg
* @param bool $valid
*
* @return \Alfred\Workflows\Result
*/
protected function setAlt($subtitle, $arg, $valid = true)
{
return $this->setMod('alt', $subtitle, $arg, $valid);
}

/**
* Converts the results to an array structured for Alfred
*
* @return array
*/
public function toArray()
{
$attrs = [
Expand Down

0 comments on commit 2fef46b

Please sign in to comment.