Code Duplication    Length = 16-18 lines in 4 locations

src/dbo/values.php 4 locations

@@ 181-196 (lines=16) @@
178
 * @param int $value Integer value to be stored in database (could be NULL).
179
 * @return int Always {@link NO_ERROR}.
180
 */
181
function value_create_number ($event_id, $field_id, $field_type = FIELD_TYPE_NUMBER, $value = NULL)
182
{
183
    debug_write_log(DEBUG_TRACE, '[value_create_number]');
184
    debug_write_log(DEBUG_DUMP,  '[value_create_number] $event_id   = ' . $event_id);
185
    debug_write_log(DEBUG_DUMP,  '[value_create_number] $field_id   = ' . $field_id);
186
    debug_write_log(DEBUG_DUMP,  '[value_create_number] $field_type = ' . $field_type);
187
    debug_write_log(DEBUG_DUMP,  '[value_create_number] $value      = ' . $value);
188
189
    dal_query('values/create.sql',
190
              $event_id,
191
              $field_id,
192
              $field_type,
193
              is_null($value) ? NULL : $value);
194
195
    return NO_ERROR;
196
}
197
198
/**
199
 * Modifies in database current integer value of specified field for specified record per specified event.
@@ 296-313 (lines=18) @@
293
 * @param string $value Float value to be stored in database (could be NULL).
294
 * @return int Always {@link NO_ERROR}.
295
 */
296
function value_create_float ($event_id, $field_id, $field_type = FIELD_TYPE_FLOAT, $value = NULL)
297
{
298
    debug_write_log(DEBUG_TRACE, '[value_create_float]');
299
    debug_write_log(DEBUG_DUMP,  '[value_create_float] $event_id   = ' . $event_id);
300
    debug_write_log(DEBUG_DUMP,  '[value_create_float] $field_id   = ' . $field_id);
301
    debug_write_log(DEBUG_DUMP,  '[value_create_float] $field_type = ' . $field_type);
302
    debug_write_log(DEBUG_DUMP,  '[value_create_float] $value      = ' . $value);
303
304
    $id = value_find_float($value);
305
306
    dal_query('values/create.sql',
307
              $event_id,
308
              $field_id,
309
              $field_type,
310
              is_null($id) ? NULL : $id);
311
312
    return NO_ERROR;
313
}
314
315
/**
316
 * Modifies in database current float value of specified field for specified record per specified event.
@@ 415-432 (lines=18) @@
412
 * @param string $value String value to be stored in database (could be NULL).
413
 * @return int Always {@link NO_ERROR}.
414
 */
415
function value_create_string ($event_id, $field_id, $field_type = FIELD_TYPE_STRING, $value = NULL)
416
{
417
    debug_write_log(DEBUG_TRACE, '[value_create_string]');
418
    debug_write_log(DEBUG_DUMP,  '[value_create_string] $event_id   = ' . $event_id);
419
    debug_write_log(DEBUG_DUMP,  '[value_create_string] $field_id   = ' . $field_id);
420
    debug_write_log(DEBUG_DUMP,  '[value_create_string] $field_type = ' . $field_type);
421
    debug_write_log(DEBUG_DUMP,  '[value_create_string] $value      = ' . $value);
422
423
    $id = value_find_string($value);
424
425
    dal_query('values/create.sql',
426
              $event_id,
427
              $field_id,
428
              $field_type,
429
              is_null($id) ? NULL : $id);
430
431
    return NO_ERROR;
432
}
433
434
/**
435
 * Modifies in database current single string value of specified field for specified record per specified event.
@@ 556-573 (lines=18) @@
553
 * @param string $value Text value to be stored in database (could be NULL).
554
 * @return int Always {@link NO_ERROR}.
555
 */
556
function value_create_multilined ($event_id, $field_id, $field_type = FIELD_TYPE_MULTILINED, $value = NULL)
557
{
558
    debug_write_log(DEBUG_TRACE, '[value_create_multilined]');
559
    debug_write_log(DEBUG_DUMP,  '[value_create_multilined] $event_id   = ' . $event_id);
560
    debug_write_log(DEBUG_DUMP,  '[value_create_multilined] $field_id   = ' . $field_id);
561
    debug_write_log(DEBUG_DUMP,  '[value_create_multilined] $field_type = ' . $field_type);
562
    debug_write_log(DEBUG_DUMP,  '[value_create_multilined] $value      = ' . $value);
563
564
    $id = value_find_multilined($value);
565
566
    dal_query('values/create.sql',
567
              $event_id,
568
              $field_id,
569
              $field_type,
570
              is_null($id) ? NULL : $id);
571
572
    return NO_ERROR;
573
}
574
575
/**
576
 * Modifies in database current multilined text value of specified field for specified record per specified event.