fix bugs, phpstan, phpcs

This commit is contained in:
Dennis Eichhorn 2020-02-06 21:04:45 +01:00
parent 21e8bb6019
commit 01eaf402b1
7 changed files with 498 additions and 217 deletions

View File

@ -1,4 +1,79 @@
{
"country": {
"name": "country",
"fields": {
"country_id": {
"name": "country_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"country_name": {
"name": "country_name",
"type": "VARCHAR(100)",
"null": false
},
"country_native": {
"name": "country_native",
"type": "VARCHAR(100)",
"null": false
},
"country_code2": {
"name": "country_code2",
"type": "VARCHAR(2)",
"null": false
},
"country_code3": {
"name": "country_code3",
"type": "VARCHAR(3)",
"null": false
},
"country_numeric": {
"name": "country_numeric",
"type": "INT(11)",
"null": false
}
}
},
"address": {
"name": "address",
"fields": {
"address_id": {
"name": "address_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"address_street": {
"name": "address_street",
"type": "VARCHAR(255)",
"null": false
},
"address_postal": {
"name": "address_postal",
"type": "VARCHAR(30)",
"null": false
},
"address_state": {
"name": "address_state",
"type": "VARCHAR(255)",
"null": false
},
"address_city": {
"name": "address_city",
"type": "VARCHAR(255)",
"null": false
},
"address_country": {
"name": "address_country",
"type": "INT",
"foreignTable": "country",
"foreignKey": "country_id"
}
}
},
"language": {
"name": "language",
"fields": {
@ -61,8 +136,8 @@
"type": "VARCHAR(5)",
"null": false
},
"currency_char": {
"name": "currency_char",
"currency_code": {
"name": "currency_code",
"type": "VARCHAR(3)",
"null": false
},
@ -78,6 +153,252 @@
}
}
},
"l11n": {
"name": "l11n",
"fields": {
"l11n_id": {
"name": "l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"l11n_country": {
"name": "l11n_country",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "country",
"foreignKey": "country_id"
},
"l11n_language": {
"name": "l11n_language",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_id"
},
"l11n_datetime": {
"name": "l11n_datetime",
"type": "INT(11)",
"default": null,
"null": true
},
"l11n_currency": {
"name": "l11n_currency",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "currency",
"foreignKey": "currency_id"
},
"l11n_number_thousand": {
"name": "l11n_number_thousand",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_number_decimal": {
"name": "l11n_number_decimal",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_angle": {
"name": "l11n_angle",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_temperature": {
"name": "l11n_temperature",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_weight_very_light": {
"name": "l11n_weight_very_light",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_weight_light": {
"name": "l11n_weight_light",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_weight_medium": {
"name": "l11n_weight_medium",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_weight_heavy": {
"name": "l11n_weight_heavy",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_weight_very_heavy": {
"name": "l11n_weight_very_heavy",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_very_slow": {
"name": "l11n_speed_very_slow",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_slow": {
"name": "l11n_speed_slow",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_medium": {
"name": "l11n_speed_medium",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_fast": {
"name": "l11n_speed_fast",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_very_fast": {
"name": "l11n_speed_very_fast",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_speed_sea": {
"name": "l11n_speed_sea",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_very_short": {
"name": "l11n_length_very_short",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_short": {
"name": "l11n_length_short",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_medium": {
"name": "l11n_length_medium",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_long": {
"name": "l11n_length_long",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_very_long": {
"name": "l11n_length_very_long",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_length_sea": {
"name": "l11n_length_sea",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_area_very_small": {
"name": "l11n_area_very_small",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_area_small": {
"name": "l11n_area_small",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_area_medium": {
"name": "l11n_area_medium",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_area_large": {
"name": "l11n_area_large",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_area_very_large": {
"name": "l11n_area_very_large",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_very_small": {
"name": "l11n_volume_very_small",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_small": {
"name": "l11n_volume_small",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_medium": {
"name": "l11n_volume_medium",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_large": {
"name": "l11n_volume_large",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_very_large": {
"name": "l11n_volume_very_large",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_teaspoon": {
"name": "l11n_volume_teaspoon",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_tablespoon": {
"name": "l11n_volume_tablespoon",
"type": "VARCHAR(20)",
"default": null,
"null": true
},
"l11n_volume_glass": {
"name": "l11n_volume_glass",
"type": "VARCHAR(20)",
"default": null,
"null": true
}
}
},
"group": {
"name": "group",
"fields": {
@ -185,217 +506,6 @@
}
}
},
"l11n": {
"name": "l11n",
"fields": {
"l11n_id": {
"name": "l11n_id",
"type": "INT",
"null": false,
"primary": true,
"autoincrement": true
},
"l11n_country": {
"name": "l11n_country",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "country",
"foreignKey": "country_id"
},
"l11n_language": {
"name": "l11n_language",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "language",
"foreignKey": "language_id"
},
"l11n_datetime": {
"name": "l11n_datetime",
"type": "INT(11)",
"null": false
},
"l11n_currency": {
"name": "l11n_currency",
"type": "INT(11)",
"default": null,
"null": true,
"foreignTable": "currency",
"foreignKey": "currency_id"
},
"l11n_number_thousand": {
"name": "l11n_number_thousand",
"type": "VARCHAR(20)",
"null": false
},
"l11n_number_decimal": {
"name": "l11n_number_decimal",
"type": "VARCHAR(20)",
"null": false
},
"l11n_angle": {
"name": "l11n_angle",
"type": "VARCHAR(20)",
"null": false
},
"l11n_temperature": {
"name": "l11n_temperature",
"type": "VARCHAR(20)",
"null": false
},
"l11n_weight_very_light": {
"name": "l11n_weight_very_light",
"type": "VARCHAR(20)",
"null": false
},
"l11n_weight_light": {
"name": "l11n_weight_light",
"type": "VARCHAR(20)",
"null": false
},
"l11n_weight_medium": {
"name": "l11n_weight_medium",
"type": "VARCHAR(20)",
"null": false
},
"l11n_weight_heavy": {
"name": "l11n_weight_heavy",
"type": "VARCHAR(20)",
"null": false
},
"l11n_weight_very_heavy": {
"name": "l11n_weight_very_heavy",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_very_slow": {
"name": "l11n_speed_very_slow",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_slow": {
"name": "l11n_speed_slow",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_medium": {
"name": "l11n_speed_medium",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_fast": {
"name": "l11n_speed_fast",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_very_fast": {
"name": "l11n_speed_very_fast",
"type": "VARCHAR(20)",
"null": false
},
"l11n_speed_sea": {
"name": "l11n_speed_sea",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_very_short": {
"name": "l11n_length_very_short",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_short": {
"name": "l11n_length_short",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_medium": {
"name": "l11n_length_medium",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_long": {
"name": "l11n_length_long",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_very_long": {
"name": "l11n_length_very_long",
"type": "VARCHAR(20)",
"null": false
},
"l11n_length_sea": {
"name": "l11n_length_sea",
"type": "VARCHAR(20)",
"null": false
},
"l11n_area_very_small": {
"name": "l11n_area_very_small",
"type": "VARCHAR(20)",
"null": false
},
"l11n_area_small": {
"name": "l11n_area_small",
"type": "VARCHAR(20)",
"null": false
},
"l11n_area_medium": {
"name": "l11n_area_medium",
"type": "VARCHAR(20)",
"null": false
},
"l11n_area_large": {
"name": "l11n_area_large",
"type": "VARCHAR(20)",
"null": false
},
"l11n_area_very_large": {
"name": "l11n_area_very_large",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_very_small": {
"name": "l11n_volume_very_small",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_small": {
"name": "l11n_volume_small",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_medium": {
"name": "l11n_volume_medium",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_large": {
"name": "l11n_volume_large",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_very_large": {
"name": "l11n_volume_very_large",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_teaspoon": {
"name": "l11n_volume_teaspoon",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_tablespoon": {
"name": "l11n_volume_tablespoon",
"type": "VARCHAR(20)",
"null": false
},
"l11n_volume_glass": {
"name": "l11n_volume_glass",
"type": "VARCHAR(20)",
"null": false
}
}
},
"account": {
"name": "account",
"fields": {

View File

@ -44,12 +44,48 @@ final class Installer extends InstallerAbstract
'database' => __DIR__ . '/../../../phpOMS/Localization/Defaults/localization.sqlite',
]);
self::installCountries($sqlite, $dbPool);
self::installLanguages($sqlite, $dbPool);
self::installCurrencies($sqlite, $dbPool);
$sqlite->close();
}
/**
* Install countries
*
* @param SQLiteConnection $sqlite SQLLite database connection of the source data
* @param DatabasePool $dbPool Database pool to save data to
*
* @return void
*
* @since 1.0.0
*/
private static function installCountries(SQLiteConnection $sqlite, DatabasePool $dbPool) : void
{
$con = $dbPool->get();
$query = new Builder($con);
$query->prefix($con->getPrefix())
->insert('country_name', 'country_native', 'country_code2', 'country_code3', 'country_numeric')
->into('country');
$querySqlite = new Builder($sqlite);
$countries = $querySqlite->select('*')->from('country')->execute();
foreach ($countries as $country) {
$query->values(
$country['country_name'],
$country['country_name'],
$country['country_code2'],
$country['country_code3'],
$country['country_numeric']
);
}
$query->execute();
}
/**
* Install languages
*

29
Models/Address.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Admin\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Admin\Models;
use phpOMS\Stdlib\Base\Location;
/**
* Address model
*
* @package Modules\Admin\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Address extends Location
{
}

79
Models/AddressMapper.php Normal file
View File

@ -0,0 +1,79 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Admin\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Admin\Models;
use phpOMS\DataStorage\Database\DataMapperAbstract;
use phpOMS\Localization\Defaults\CountryMapper;
/**
* Address mapper class.
*
* @package Modules\Admin\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class AddressMapper extends DataMapperAbstract
{
/**
* Columns.
*
* @var array<string, array<string, bool|string>>
* @since 1.0.0
*/
protected static array $columns = [
'address_id' => ['name' => 'address_id', 'type' => 'int', 'internal' => 'id'],
'address_street' => ['name' => 'address_street', 'type' => 'string', 'internal' => 'address'],
'address_postal' => ['name' => 'address_postal', 'type' => 'string', 'internal' => 'postal'],
'address_state' => ['name' => 'address_state', 'type' => 'string', 'internal' => 'state'],
'address_city' => ['name' => 'address_city', 'type' => 'string', 'internal' => 'city'],
'address_country' => ['name' => 'address_country', 'type' => 'int', 'internal' => 'country'],
];
/**
* Has one relation.
*
* @todo Orange-Management/phpOMS#224
* Implement composite models.
* If a column is defined only that column value should get populated in the model and not the full model!
* OwnsOne, HasOne, use single value instead of full model defined in the mapper.
*
* @var array<string, array<string, string>>
* @since 1.0.0
*/
protected static array $ownsOne = [
'country' => [
'mapper' => CountryMapper::class,
'column' => '',
'src' => 'address_country',
],
];
/**
* Primary table.
*
* @var string
* @since 1.0.0
*/
protected static string $table = 'address';
/**
* Primary field name.
*
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'address_id';
}

View File

@ -51,7 +51,7 @@ class Group extends \phpOMS\Account\Group
/**
* Accounts
*
* @var array
* @var Account[]|int[]
* @since 1.0.0
*/
protected array $accounts = [];

View File

@ -37,9 +37,6 @@ final class LocalizationMapper extends DataMapperAbstract
*/
protected static array $columns = [
'l11n_id' => ['name' => 'l11n_id', 'type' => 'int', 'internal' => 'id'],
'l11n_country' => ['name' => 'l11n_country', 'type' => 'int', 'internal' => 'country'],
'l11n_language' => ['name' => 'l11n_language', 'type' => 'int', 'internal' => 'language'],
'l11n_currency' => ['name' => 'l11n_currency', 'type' => 'int', 'internal' => 'currency'],
'l11n_datetime' => ['name' => 'l11n_datetime', 'type' => 'int', 'internal' => 'datetime'],
'l11n_number_thousand' => ['name' => 'l11n_number_thousand', 'type' => 'string', 'internal' => 'thousands'],
'l11n_number_decimal' => ['name' => 'l11n_number_decimal', 'type' => 'string', 'internal' => 'decimal'],
@ -57,14 +54,17 @@ final class LocalizationMapper extends DataMapperAbstract
'country' => [
'mapper' => CountryMapper::class,
'src' => 'l11n_country',
'ref' => 'country_code2'
],
'language' => [
'mapper' => LanguageMapper::class,
'src' => 'l11n_language',
'ref' => 'language_639_2T'
],
'currency' => [
'mapper' => CurrencyMapper::class,
'src' => 'l11n_currency',
'ref' => 'currency_code'
],
];

27
Models/NullAddress.php Normal file
View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Admin\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Admin\Models;
/**
* Null model
*
* @package Modules\Admin\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
final class NullAddress extends Address
{
}