Skip to content

Commit

Permalink
Merge pull request #13 from apple-x-co/refactor-slack
Browse files Browse the repository at this point in the history
refactor slack
  • Loading branch information
apple-x-co authored Apr 4, 2021
2 parents 77ad70f + a7e27e2 commit 18b975f
Show file tree
Hide file tree
Showing 24 changed files with 1,052 additions and 699 deletions.
34 changes: 0 additions & 34 deletions src/ArchiverCommand.php

This file was deleted.

13 changes: 0 additions & 13 deletions src/ArchiverInterface.php

This file was deleted.

40 changes: 0 additions & 40 deletions src/ArchiverZip.php

This file was deleted.

44 changes: 44 additions & 0 deletions src/Chunker.php
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;
}
}
71 changes: 0 additions & 71 deletions src/Color.php

This file was deleted.

50 changes: 50 additions & 0 deletions src/ColorOutput.php
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;
}
}
Loading

0 comments on commit 18b975f

Please sign in to comment.