Comments and tests
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good
All checks were successful
timw4mail/php-kilo/pipeline/head This commit looks good
This commit is contained in:
parent
3ef4268263
commit
457560137d
@ -3,7 +3,12 @@
|
||||
namespace Aviat\Kilo;
|
||||
|
||||
class FileType {
|
||||
|
||||
/**
|
||||
* Create the FileType object from the filename
|
||||
*
|
||||
* @param string|null $filename
|
||||
* @return self
|
||||
*/
|
||||
public static function from(?string $filename): self
|
||||
{
|
||||
$syntax = self::getSyntaxFromFilename((string)$filename);
|
||||
@ -11,6 +16,12 @@ class FileType {
|
||||
return new self($syntax->filetype, $syntax);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Syntax object from the filename
|
||||
*
|
||||
* @param string $filename
|
||||
* @return Syntax
|
||||
*/
|
||||
private static function getSyntaxFromFilename(string $filename): Syntax
|
||||
{
|
||||
$ext = strstr(basename($filename), '.');
|
||||
|
@ -11,8 +11,6 @@ use Aviat\Kilo\Enum\RawKeyCode;
|
||||
* @property-read string $chars
|
||||
*/
|
||||
class Row {
|
||||
// use Traits\MagicProperties;
|
||||
|
||||
/**
|
||||
* The version of the row to be displayed (where tabs are converted to display spaces)
|
||||
*/
|
||||
|
@ -41,7 +41,15 @@ class Syntax {
|
||||
|
||||
public static function default(): self
|
||||
{
|
||||
return self::new('No filetype', slcs: '', mcs: '', mce: '', highlightNumbers: false, highlightStrings: false, hasCommonOperators: false);
|
||||
return self::new(
|
||||
'No filetype', slcs:
|
||||
'', mcs:
|
||||
'', mce:
|
||||
'',
|
||||
highlightNumbers: false,
|
||||
highlightStrings: false,
|
||||
hasCommonOperators: false,
|
||||
);
|
||||
}
|
||||
|
||||
private function __construct(
|
||||
@ -57,7 +65,7 @@ class Syntax {
|
||||
public string $singleLineCommentStart,
|
||||
/** Syntax to start a multi-line comment */
|
||||
public string $multiLineCommentStart,
|
||||
/** Syntax to end a multi-line commment */
|
||||
/** Syntax to end a multi-line comment */
|
||||
public string $multiLineCommentEnd,
|
||||
/** Should we highlight numbers? */
|
||||
private bool $highlightNumbers,
|
||||
|
24
tests/Type/PointTest.php
Normal file
24
tests/Type/PointTest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Aviat\Kilo\Tests\Type;
|
||||
|
||||
use Aviat\Kilo\Type\Point;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PointTest extends TestCase {
|
||||
public function testNewPoint(): void
|
||||
{
|
||||
$p = Point::new(1, 2);
|
||||
$this->assertEquals(1, $p->x);
|
||||
$this->assertEquals(2, $p->y);
|
||||
}
|
||||
|
||||
public function testPointFrom(): void
|
||||
{
|
||||
$p = Point::new(3, 7);
|
||||
$p2 = Point::from($p);
|
||||
|
||||
$this->assertEquals($p->x, $p2->x);
|
||||
$this->assertEquals($p->y, $p2->y);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user