first commit

This commit is contained in:
2020-10-20 09:32:09 +02:00
commit e64b18b9a9
4183 changed files with 488526 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
<?php
namespace League\CLImate\Util;
use League\CLImate\Util\System\SystemFactory;
use League\CLImate\Util\System\System;
class UtilFactory
{
/**
* A instance of the appropriate System class
*
* @var \League\CLImate\Util\System\System
*/
public $system;
/**
* A instance of the Cursor class
*
* @var \League\CLImate\Util\Cursor
*/
public $cursor;
public function __construct(System $system = null, Cursor $cursor = null)
{
$this->system = $system ?: SystemFactory::getInstance();
$this->cursor = $cursor ?: new Cursor();
}
/**
* Get the width of the terminal
*
* @return integer
*/
public function width()
{
return (int) $this->getDimension($this->system->width(), 80);
}
/**
* Get the height of the terminal
*
* @return integer
*/
public function height()
{
return (int) $this->getDimension($this->system->height(), 25);
}
/**
* Determine if the value is numeric, fallback to a default if not
*
* @param integer|null $dimension
* @param integer $default
*
* @return integer
*/
protected function getDimension($dimension, $default)
{
return (is_numeric($dimension)) ? $dimension : $default;
}
}