-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52d5569
commit aa08072
Showing
3 changed files
with
67 additions
and
30 deletions.
There are no files selected for viewing
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
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
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,64 @@ | ||
<?php | ||
/** | ||
* Part of earth project. | ||
* | ||
* @copyright Copyright (C) 2018 ${ORGANIZATION}. | ||
* @license __LICENSE__ | ||
*/ | ||
|
||
namespace Windwalker\Core\Seeder; | ||
|
||
use Windwalker\Console\Command\Command; | ||
use Windwalker\Environment\PlatformHelper; | ||
|
||
/** | ||
* The CountingOutputTrait class. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
trait CountingOutputTrait | ||
{ | ||
/** | ||
* Property count. | ||
* | ||
* @var int | ||
*/ | ||
protected $count = 0; | ||
|
||
/** | ||
* outCounting | ||
* | ||
* @return Command | ||
*/ | ||
public function outCounting() | ||
{ | ||
// @see https://gist.github.com/asika32764/19956edcc5e893b2cbe3768e91590cf1 | ||
if (PlatformHelper::isWindows()) { | ||
$loading = ['|', '/', '-', '\\']; | ||
} else { | ||
$loading = ['◐', '◓', '◑', '◒']; | ||
} | ||
|
||
$this->count++; | ||
|
||
$icon = $loading[$this->count % count($loading)]; | ||
|
||
$this->command->out("\r ({$this->count}) $icon ", false); | ||
|
||
return $this->command; | ||
} | ||
|
||
/** | ||
* resetCount | ||
* | ||
* @return $this | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function resetCount() | ||
{ | ||
$this->count = 0; | ||
|
||
return $this; | ||
} | ||
} |