2017 © Pedro Pelรกez
 

library php7-sie

PHP 7 version of Neam's PHP implementation https://github.com/neam/php-sie

image

dnyg/php7-sie

PHP 7 version of Neam's PHP implementation https://github.com/neam/php-sie

  • Monday, April 9, 2018
  • by danyg
  • Repository
  • 1 Watchers
  • 0 Stars
  • 399 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 80 % Grown

The README.md

Requires PHP 7.1 or greater, (*1)

Generating a SIE file

To generate a SIE document you first need to define a class that extends the abstract class \sie\document\DataSource., (*2)

$mySieFileDataSource = new MySieFileDataSource($this);
$sieFileDocument = $mySieFileDataSource->generateSieDocument();
$sieFileContents = $sieFileDocument->render();
file_put_contents('sie_file.se', $sieFileContents);

Check the files in tests/unit/*Test.php for more examples., (*3)

Parsing a SIE file

You can parse sie data from anything that responds to each_line like a file or a string., (*4)

$file_contents = file_get_contents('sie_file.se');
$parser = new \sie\Parser();
$sie_file = $parser->parseSieFileContents($file_contents);
return $this->parse($data);

The parser expects file contents in CP437 encoding (the official encoding of the SIE file format)., (*5)

If you want to parse UTF8 strings, use the "parse" method:, (*6)

$sie_file = $parser->parse($utf8_string);

By default the parser will raise an error if it encounters unknown entry types. Use the lenient option to avoid this:, (*7)

$parser = new \sie\Parser(["lenient" => true]);

Check the files in tests/integration/*Test.php for more examples., (*8)

Developing

First time setup:, (*9)

composer install

Running tests:, (*10)

vendor/bin/codecept build
vendor/bin/codecept run

Tests sample output:, (*11)

# vendor/bin/codecept run --debug
Codeception PHP Testing Framework v2.2.4
Powered by PHPUnit 5.4.8 by Sebastian Bergmann and contributors.

Integration Tests (8) ----------------------------------------------------------------------------------------------
Modules: \Helper\Integration
--------------------------------------------------------------------------------------------------------------------
โœ” FileParserTest: Parses a file (0.07s)
โœ” FileParserTest: Parses a file with unknown entries using a lenient parser (0.01s)
โœ” FileParserTest: Parses a file with unknown entries using a strict parser (0.05s)
โœ” Fortnox21FileParserTest: Parses sie1 se file (0.09s)
โœ” Fortnox21FileParserTest: Parses sie2 se file (0.25s)
โœ” Fortnox21FileParserTest: Parses sie3 se file (0.27s)
โœ” Fortnox21FileParserTest: Parses sie4 se file (0.51s)
โœ” Fortnox21FileParserTest: Parses sie4 si file (0.29s)
--------------------------------------------------------------------------------------------------------------------

Unit Tests (39) ----------------------------------------------------------------------------------------------------
Modules: \Helper\Unit
--------------------------------------------------------------------------------------------------------------------
โœ” BuildEntryTest: Call (0.05s)
โœ” BuildEntryTest: Call with an unquoted zero string (0.00s)
โœ” BuildEntryTest: Call with short dimensions array (0.00s)
โœ” BuildEntryTest: Call with long dimensions array (0.00s)
โœ” BuildEntryTest: Call with simple attribute (0.00s)
โœ” BuildEntryTest: Call with an unexpected token at start of array (0.00s)
โœ” DocumentTest: Adds a header (0.02s)
โœ” DocumentTest: Has accounting years (0.01s)
โœ” DocumentTest: Has accounts (0.01s)
โœ” DocumentTest: Has dimensions (0.01s)
โœ” DocumentTest: Has objects (0.01s)
โœ” DocumentTest: Has balances brought forward (0.01s)
โœ” DocumentTest: Has balances carried forward (0.01s)
โœ” DocumentTest: Has closing account balances (0.01s)
โœ” DocumentTest: Has vouchers (0.01s)
โœ” DocumentTest: Truncates really long descriptions (0.01s)
โœ” DocumentTest: Ensures there are at least two lines with a zeroed single voucher line (0.01s)
โœ” DocumentTest: Reads the series from the voucher with a series defined (0.01s)
โœ” ParserTest: Parses sie data that includes arrays (0.00s)
โœ” ParserTest: Handles leading whitespace (0.00s)
โœ” RendererTest: Replaces input of the wrong encoding with questionmark (0.00s)
โœ” VoucherSeriesTest: Self for | #0 (0.00s)
โœ” VoucherSeriesTest: Self for | #1 (0.00s)
โœ” VoucherSeriesTest: Self for | #2 (0.00s)
โœ” VoucherSeriesTest: Self for | #3 (0.00s)
โœ” VoucherSeriesTest: Self for | #4 (0.00s)
โœ” LineParserTest: It parses lines from a sie file (0.00s)
โœ” LineParserTest: Using a lenient parser it raises no error when encountering unknown entries (0.00s)
โœ” LineParserTest: Using a strict parser it raises error when encountering unknown entries (0.00s)
โœ” TokenizerTest: Tokenizes the given line (0.00s)
โœ” TokenizerTest: Can parse metadata arrays (0.00s)
โœ” TokenizerTest: Handles escaped quotes in quoted strings (0.00s)
โœ” TokenizerTest: Handles escaped quotes in non quoted strings (0.00s)
โœ” TokenizerTest: Handles escaped backslash in strings (0.00s)
โœ” TokenizerTest: Has reasonable behavior for consecutive escape characters (0.00s)
โœ” TokenizerTest: Handles tab character as field separator (0.00s)
โœ” TokenizerTest: Handles unquoted zeros (0.01s)
โœ” TokenizerTest: Handles transaction with dimension array (0.00s)
โœ” TokenizerTest: Rejects control characters (0.00s)
--------------------------------------------------------------------------------------------------------------------


Time: 2.84 seconds, Memory: 12.00MB

OK (47 tests, 133 assertions)

The Versions

09/04 2018

dev-master

9999999-dev https://github.com/DanygNet/php7-sie

PHP 7 version of Neam's PHP implementation https://github.com/neam/php-sie

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Nygaard

php php7 sie

09/04 2018

3.3.3.3

3.3.3.3 https://github.com/DanygNet/php7-sie

PHP 7 version of Neam's PHP implementation https://github.com/neam/php-sie

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Nygaard

php php7 sie

05/07 2017

dev-develop

dev-develop https://github.com/neam/php-sie

PHP port of https://github.com/barsoom/sie

  Sources   Download

MIT

The Requires

 

The Development Requires

by Contributors of barsoom/sie - https://github.com/barsoom/sie/graphs/contributors

php sie

05/10 2016

3.3.3.1

3.3.3.1 https://github.com/neam/php-sie

PHP port of https://github.com/barsoom/sie

  Sources   Download

MIT

The Requires

 

The Development Requires

by Contributors of barsoom/sie - https://github.com/barsoom/sie/graphs/contributors

php sie

21/09 2016

3.3.3.0

3.3.3.0 https://github.com/neam/php-sie

PHP port of https://github.com/barsoom/sie

  Sources   Download

MIT

The Requires

 

The Development Requires

by Contributors of barsoom/sie - https://github.com/barsoom/sie/graphs/contributors

php sie