Skip to content

Commit

Permalink
Support fluent interface e.g., $this->foo()->bar()->etc()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariano Peterson committed Feb 7, 2011
1 parent 5f10ff4 commit 143a13c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
18 changes: 9 additions & 9 deletions CliParser.php
Expand Up @@ -18,14 +18,14 @@ class CliParser
const TYPE_FLAG = 2;

/**
* @var int Indicates an input option can be provided as a
* @var int Indicates an input option can be provided as a
* key/value pair multiple times.
* (i.e., "--var=foo --var=bar" or "--var=foo,bar")
* (i.e., "--var=foo --var=bar" or "--var=foo,bar")
*/
const TYPE_ARRAY = 3;

/**
* @var string the delimiter to use with self::TYPE_ARRAY
* @var string the delimiter to use with self::TYPE_ARRAY
*/
const DEFAULT_DELIMITER = ',';

Expand Down Expand Up @@ -90,11 +90,11 @@ public function about($msg)
* @return Opt (supports fluent interface)
*/
public function addOpt(
$short,
$long,
$help,
$required = false,
$type = self::TYPE_VALUE,
$short,
$long,
$help,
$required = false,
$type = self::TYPE_VALUE,
$delimiter = self::DEFAULT_DELIMITER
)
{
Expand Down
9 changes: 2 additions & 7 deletions Slog.php
Expand Up @@ -166,20 +166,18 @@ public function fetchXml($cmd)
*
* @param string|array<string> $author Author(s) whose commits will be removed.
*
* @return void
* @return Slog (supports fluent interface)
*/
public function removeCommitsFromAuthor($author)
{
if (!is_array($author)) {
$author = explode(',', $author);
}
$author = array_filter($author);
if (empty($author)) {
return;
}
foreach ($author as $a) {
$this->removeAuthors[$a] = 1;
}
return $this;
}

/**
Expand All @@ -195,9 +193,6 @@ public function matchAuthor($author)
$author = explode(',', $author);
}
$author = array_filter($author);
if (empty($author)) {
return;
}
foreach ($author as $a) {
$this->mustMatchAuthors[$a] = 1;
}
Expand Down

0 comments on commit 143a13c

Please sign in to comment.