Exemple #1
0
{
    function __invoke($string = null)
    {
        $obj = new Colors\Color($string);
        return $obj;
    }
}
$c = new Kolor();
$c = new Colors\Color();
function color($string)
{
    return new Colors\Color($string);
}
echo color('Hello World!')->red()->white() . color("some other text 1 ")->green() . color("some other text 2 ")->blue() . color("some other text 3 ")->yellow() . color("some other text 4 ")->white() . PHP_EOL;
exit;
print "we r here \n";
print $c->red("this is red") . "\n";
print $c->bold($c->red("this is red and bold")) . "\n";
print $c("also this is red and bold")->red->bold . "\n";
$c("this is some text");
var_dump($c);
print "===============================================================\n";
$c("this is some text")->red();
var_dump($c);
print "===============================================================\n";
$c("different text");
var_dump($c);
print "===============================================================\n";
$c("different text")->blue();
var_dump($c);
print "===============================================================\n";
Exemple #2
0
 /**
  * @return string
  */
 public function getHelp()
 {
     $color = new \Colors\Color();
     $help = '';
     $isNamed = $this->type & self::TYPE_NAMED;
     if ($isNamed) {
         $help .= PHP_EOL . (mb_strlen($this->name, 'UTF-8') === 1 ? '-' : '--') . $this->name;
         if (!empty($this->aliases)) {
             foreach ($this->aliases as $alias) {
                 $help .= (mb_strlen($alias, 'UTF-8') === 1 ? '/-' : '/--') . $alias;
             }
         }
         if (!$this->isBoolean()) {
             $help .= ' ' . $color->underline('<argument>');
         }
         $help .= PHP_EOL;
     } else {
         $help .= (empty($this->title) ? "arg {$this->name}" : $this->title) . PHP_EOL;
     }
     // bold what has been displayed so far
     $help = $color->bold($help);
     $titleLine = '';
     if ($isNamed && $this->title) {
         $titleLine .= $this->title . '.';
         if ($this->isRequired()) {
             $titleLine .= ' ';
         }
     }
     if ($this->isRequired()) {
         $titleLine .= $color->red('Required.');
     }
     if ($titleLine) {
         $titleLine .= ' ';
     }
     $description = $titleLine . $this->description;
     if (!empty($description)) {
         $descriptionArray = explode(PHP_EOL, trim($description));
         foreach ($descriptionArray as $descriptionLine) {
             $help .= Terminal::wrap($descriptionLine, 5, 1) . PHP_EOL;
         }
     }
     return $help;
 }