Improve code style a bit
phpcs-errors:243 phpunit-status:successful
This commit is contained in:
parent
18962df768
commit
5af012ba8b
|
@ -64,7 +64,8 @@ $fp = fopen ( $csv_datei, 'r' );
|
|||
$y = 1;
|
||||
$error = 0;
|
||||
$zeile = fgetcsv( $fp, 100000, ';' );
|
||||
for ($x = 0; $x < count($zeile); $x++) {
|
||||
$maxLoopLen = count($zeile);
|
||||
for ($x = 0; $x < $maxLoopLen; $x++) {
|
||||
|
||||
$zeile[$x] = str_replace("\xEF\xBB\xBF", "", $zeile[$x]);
|
||||
$inhalt[$y][$x] = $zeile[$x];
|
||||
|
@ -98,7 +99,8 @@ $y = 0;
|
|||
while ($zeile = fgetcsv($fp, 100000, ';')) {
|
||||
|
||||
$y++;
|
||||
for ($x = 0; $x < count ( $zeile ); $x++) {
|
||||
$maxLoopLen = count($zeile);
|
||||
for ($x = 0; $x < $maxLoopLen; $x++) {
|
||||
$inhalt[$y][$x] = str_replace("'", "\'", $zeile[$x]);
|
||||
}
|
||||
}
|
||||
|
@ -109,27 +111,34 @@ echo '<br><br>3: Mandatory tags available and always filled in?';
|
|||
unset($inv_array);
|
||||
$inv_error = 0;
|
||||
|
||||
function get_duplicates($array) {
|
||||
/**
|
||||
* Function for finding duplicates?.
|
||||
*
|
||||
* @param array $array Input array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_duplicates(array $array):array {
|
||||
return array_unique(array_diff_assoc($array, array_unique($array)));
|
||||
|
||||
}
|
||||
|
||||
$mandatory = ['inventory_number','object_type','object_title','object_description'];
|
||||
for ($i = 0; $i < count($mandatory); $i++) {
|
||||
if (!in_array($mandatory[$i], $erstezeile)) {
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Mandatory: Column <b>' . $mandatory[$i] . '</b> missing</i>';
|
||||
foreach ($mandatory as $tMandatoryField) {
|
||||
if (!in_array($tMandatoryField, $erstezeile)) {
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Mandatory: Column <b>' . $tMandatoryField . '</b> missing</i>';
|
||||
$error = $error + 1;
|
||||
$inv_error = $inv_error + 1;
|
||||
}
|
||||
else {
|
||||
$spaltenr = array_search($mandatory[$i], $erstezeile);
|
||||
$spaltenr = array_search($tMandatoryField, $erstezeile);
|
||||
for ($j = 0; $j < $y; $j++) {
|
||||
if ($inhalt[$j + 1][$spaltenr] == '') {
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Missing value for <b>' . $mandatory[$i] . '</b> in row ' . ($j + 1) . '</i>';
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Missing value for <b>' . $tMandatoryField . '</b> in row ' . ($j + 1) . '</i>';
|
||||
$error = $error + 1;
|
||||
$inv_error = $inv_error + 1;
|
||||
}
|
||||
if ($mandatory[$i] == 'inventory_number') {
|
||||
if ($tMandatoryField == 'inventory_number') {
|
||||
$inv_array[] = $inhalt[$j + 1][$spaltenr];
|
||||
}
|
||||
}
|
||||
|
@ -143,17 +152,15 @@ echo '<br><br>4: Inventory_number unique ?';
|
|||
if (in_array('inventory_number', $erstezeile)) {
|
||||
$doppelte_inv = get_duplicates($inv_array);
|
||||
$doppelte_inv = array_values($doppelte_inv);
|
||||
if (count($doppelte_inv) > 0) {
|
||||
for ($i = 0; $i < count($doppelte_inv); $i++)
|
||||
{
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Multiple use of inventory_number <b>' . $doppelte_inv[$i] . '</b></i>';
|
||||
if (!empty($doppelte_inv)) {
|
||||
foreach ($doppelte_inv as $tDublicateInvNo) {
|
||||
echo '<br><i style="font-style:normal;color:#990000;">Multiple use of inventory_number <b>' . $tDublicateInvNo . '</b></i>';
|
||||
$error = $error + 1;
|
||||
}
|
||||
}
|
||||
else echo '<br><i style="font-style:normal;color:#009900;">All inventory_numbers are unique !</i>';
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
echo '<br><b style="font-style:normal;color:#990000;">Aborted, column inventory_number is missing</b>';
|
||||
$error = $error + 1;
|
||||
}
|
||||
|
@ -175,11 +182,10 @@ foreach ($fieldsWithDependency as $tField => $tDependentFields) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($depencymessage) and $depencymessage != '') {
|
||||
if (!empty($depencymessage)) {
|
||||
echo '<b style="color:#990000;">Dependent columns were not observed !</b>';
|
||||
for ($i = 0; $i < count ($depencymessage); $i++)
|
||||
{
|
||||
echo '<br>' . $depencymessage[$i];
|
||||
foreach ($depencymessage as $tDepMsg) {
|
||||
echo '<br>' . $tDepMsg;
|
||||
$error = $error + 1;
|
||||
}
|
||||
}
|
||||
|
@ -194,14 +200,14 @@ $crosscheck1 = ['object_other_title','detailed_description','detailed_descriptio
|
|||
$crosscheck2 = ['object_other_title_kind_of','detailed_description_md','detailed_description_extern','inscription_md','inscription_extern','dimensions_separate_length_unit', 'dimensions_separate_width_unit', 'dimensions_separate_height_unit', 'dimensions_separate_diameter_unit', 'dimensions_separate_wall_thickness_unit', 'dimensions_separate_weight_unit','closer_location_as','bought_for_currency','worth_unit','worth_insurance_unit'];
|
||||
|
||||
$depcon_error = 0;
|
||||
for ($l = 0; $l < count($crosscheck1); $l++) {
|
||||
foreach ($crosscheck1 as $tCrossCheck) {
|
||||
|
||||
if (in_array($crosscheck1[$l], $erstezeile)) {
|
||||
if (in_array($tCrossCheck, $erstezeile)) {
|
||||
|
||||
for ($j = 1; $j < ($y + 1); $j++) {
|
||||
if ($inhalt[$j][array_search($crosscheck2[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($crosscheck1[$l], $erstezeile)] == '') {
|
||||
echo '<br>Tag <b>' . $crosscheck2[$l] . '</b> given but no entry for <b>' . $crosscheck1[$l] . '</b> (row ' . $j . ')';
|
||||
$depcon_error = $depcon_error + 1;
|
||||
if ($inhalt[$j][array_search($crosscheck2[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tCrossCheck, $erstezeile)] == '') {
|
||||
echo '<br>Tag <b>' . $crosscheck2[$l] . '</b> given but no entry for <b>' . $tCrossCheck . '</b> (row ' . $j . ')';
|
||||
$depcon_error++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +220,7 @@ for ($l = 0; $l < count($eventpart); $l++) {
|
|||
for ($j = 1; $j < ($y + 1); $j++) {
|
||||
if ($inhalt[$j][array_search($eventpartsure[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($eventpart[$l], $erstezeile)] == '') {
|
||||
echo '<br>Tag <b>' . $eventpartsure[$l] . '</b> given but no entry for <b>' . $eventpart[$l] . '</b> (row ' . $j . ')';
|
||||
$depcon_error = $depcon_error + 1;
|
||||
$depcon_error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user