germania-kg/itemcodes

2.1.2 2022-05-30 13:28 UTC

README

Packagist PHP version Build Status Scrutinizer Code Quality Code Coverage Build Status

Installation with Composer

$ composer require germania-kg/itemcodes

Make sure the itemcodes table exists; see Database section.

Database

Setup the MySQL table itemcodes as described in sql/itemcodes.sql.txt. Rename the table if needed.

Usage

ItemCode

<?php
use Germania\Nav\ItemCodes\ItemCode;

$itemcode = new ItemCode;
$itemcode->setCode("COD")->setName("The Code Name");

InsertOrUpdateItemCode

This action class requires at least a PDO handle an a table name to work with. A PSR-3 Logger is optional.

<?php
use Germania\Nav\ItemCodes\Actions\InsertOrUpdateItemCode;

// Setup ingredients
$pdo = new \PDO( ... );
$table = "my_itemcodes";

// Optional PSR-3 Logger
$logger = ...

$inserter = new InsertOrUpdateItemCode( $pdo, $table);
$inserter = new InsertOrUpdateItemCode( $pdo, $table, $logger);

// Both are equal:
$result = $insert_or_update( $itemcode );
$result = $insert_or_update->execute( $itemcode );

// $result is 1 when ItemCode has been INSERTed,
// and 2, when REPLACEd

Issues

See issues list.

Development

$ git clone https://github.com/GermaniaKG/ItemCodes.git
$ cd ItemCodes
$ composer install

Unit tests

Either copy phpunit.xml.dist to phpunit.xml and adapt to your needs, or leave as is. Run PhpUnit test or composer scripts like this:

$ composer test
# or
$ vendor/bin/phpunit