-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from apple-x-co/refactor-slack
refactor slack
- Loading branch information
Showing
24 changed files
with
1,052 additions
and
699 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Rocket; | ||
|
||
class Chunker | ||
{ | ||
/** | ||
* @param string $text | ||
* @param int $length | ||
* | ||
* @return array<string> | ||
*/ | ||
public function __invoke($text, $length) | ||
{ | ||
$chunks = []; | ||
$buf = null; | ||
|
||
$lines = explode(PHP_EOL, $text); | ||
foreach ($lines as $line) { | ||
if (strlen($line) >= $length) { | ||
foreach (str_split($line, $length) as $chunk) { | ||
$chunks[] = $chunk; | ||
} | ||
|
||
continue; | ||
} | ||
|
||
$line .= PHP_EOL; | ||
|
||
if (strlen($buf . $line) > $length) { | ||
$chunks[] = $buf; | ||
$buf = null; | ||
} | ||
|
||
$buf .= $line; | ||
} | ||
|
||
if ($buf !== null) { | ||
$chunks[] = $buf; | ||
} | ||
|
||
return $chunks; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Rocket; | ||
|
||
class ColorOutput implements OutputInterface | ||
{ | ||
/** | ||
* @param string $text | ||
*/ | ||
public function plain($text) | ||
{ | ||
echo $text . PHP_EOL; | ||
} | ||
|
||
/** | ||
* @param string $text | ||
*/ | ||
public function error($text) | ||
{ | ||
$escapeSequence = new EscapeSequence('red', null, ['bold']); | ||
echo $escapeSequence->apply($text) . PHP_EOL; | ||
} | ||
|
||
/** | ||
* @param string $text | ||
*/ | ||
public function warning($text) | ||
{ | ||
$escapeSequence = new EscapeSequence('magenta', null, ['bold']); | ||
echo $escapeSequence->apply($text) . PHP_EOL; | ||
} | ||
|
||
/** | ||
* @param string $text | ||
*/ | ||
public function info($text) | ||
{ | ||
$escapeSequence = new EscapeSequence('cyan', null, ['bold']); | ||
echo $escapeSequence->apply($text) . PHP_EOL; | ||
} | ||
|
||
/** | ||
* @param string $text | ||
*/ | ||
public function debug($text) | ||
{ | ||
$escapeSequence = new EscapeSequence(null, null, ['underline', 'brink']); | ||
echo $escapeSequence->apply($text) . PHP_EOL; | ||
} | ||
} |
Oops, something went wrong.