Skip to content

Commit

Permalink
Table getLanguageCode
Browse files Browse the repository at this point in the history
  • Loading branch information
gam6itko committed Aug 3, 2020
1 parent f2491e9 commit 397013e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/XBase/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use XBase\Column\ColumnFactory;
use XBase\Column\ColumnInterface;
use XBase\Column\DBase7Column;
use XBase\Enum\Codepage;
use XBase\Enum\TableType;
use XBase\Exception\TableException;
use XBase\Memo\MemoFactory;
Expand Down Expand Up @@ -54,9 +55,12 @@ class Table
public $encrypted;
/** @var string */
public $mdxFlag;

/**
* @var string Language codepage.
* @see https://blog.codetitans.pl/post/dbf-and-language-code-page/
*
* @deprecated in 1.2 and will be protected in 1.3. Use getLanguageCode() method.
*/
public $languageCode;

Expand Down Expand Up @@ -411,6 +415,16 @@ public function getVersion()
return $this->version;
}

/**
* @see Codepage
*
* @return int
*/
public function getLanguageCode(): int
{
return ord($this->languageCode);
}

public function getMemo(): ?MemoInterface
{
return $this->memo;
Expand Down
6 changes: 3 additions & 3 deletions tests/DBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testRead(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::NONE, ord($table->mdxFlag));
self::assertSame(0, ord($table->languageCode));
self::assertSame(0, $table->getLanguageCode());

$columns = $table->getColumns();
self::assertIsArray($columns);
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testDbase3(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::NONE, ord($table->mdxFlag));
self::assertSame(0x03, ord($table->languageCode));
self::assertSame(0x03, $table->getLanguageCode());

$this->assertRecords($table);
$this->assertMemoImg($table);
Expand All @@ -200,7 +200,7 @@ public function testDbase4(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::NONE, ord($table->mdxFlag));
self::assertSame(0x03, ord($table->languageCode));
self::assertSame(0x03, $table->getLanguageCode());

$this->assertRecords($table);
$this->assertMemoImg($table);
Expand Down
4 changes: 2 additions & 2 deletions tests/FoxproTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function testRead(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::NONE, ord($table->mdxFlag));
self::assertSame(0x64, ord($table->languageCode));
self::assertSame(0x64, $table->getLanguageCode());

self::assertSame(12, $table->getColumnCount());
// self::assertSame(10, $table->getRecordCount());
Expand Down Expand Up @@ -67,7 +67,7 @@ public function testFoxpro2(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::NONE, ord($table->mdxFlag));
self::assertSame(0x03, ord($table->languageCode));
self::assertSame(0x03, $table->getLanguageCode());

$this->assertRecords($table);
$this->assertMemoImg($table);
Expand Down
4 changes: 2 additions & 2 deletions tests/VisualFoxproTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testRead(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::CDX | TableFlag::MEMO, ord($table->mdxFlag));
self::assertSame(0x03, ord($table->languageCode));
self::assertSame(0x03, $table->getLanguageCode());
self::assertSame(15, $table->getColumnCount());
self::assertSame(0, $table->getRecordCount());

Expand Down Expand Up @@ -64,7 +64,7 @@ public function testVfp(): void
self::assertSame(false, $table->inTransaction);
self::assertSame(false, $table->encrypted);
self::assertSame(TableFlag::MEMO, ord($table->mdxFlag));
self::assertSame(0x03, ord($table->languageCode));
self::assertSame(0x03, $table->getLanguageCode());

$columns = $table->getColumns();

Expand Down

0 comments on commit 397013e

Please sign in to comment.