Code Duplication    Length = 42-42 lines in 2 locations

statisticsplot.php 2 locations

@@ 301-342 (lines=42) @@
298
 *
299
 * @return int
300
 */
301
function lifespan_by_birth_year($z_axis, array $z_boundaries, Stats $stats) {
302
	$total = 0;
303
304
	if ($z_axis === 300) {
305
		$num = $stats->statsAgeQuery(false, 'BIRT');
306
		foreach ($num as $values) {
307
			foreach ($values as $age_value) {
308
				fill_y_data(0, (int) ($age_value / 365.25), 1);
309
				$total++;
310
			}
311
		}
312
	} elseif ($z_axis === 301) {
313
		$num = $stats->statsAgeQuery(false, 'BIRT', 'M');
314
		foreach ($num as $values) {
315
			foreach ($values as $age_value) {
316
				fill_y_data(0, (int) ($age_value / 365.25), 1);
317
				$total++;
318
			}
319
		}
320
		$num = $stats->statsAgeQuery(false, 'BIRT', 'F');
321
		foreach ($num as $values) {
322
			foreach ($values as $age_value) {
323
				fill_y_data(1, (int) ($age_value / 365.25), 1);
324
				$total++;
325
			}
326
		}
327
	} else {
328
		$zstart = 0;
329
		foreach ($z_boundaries as $boundary) {
330
			$num = $stats->statsAgeQuery(false, 'BIRT', 'BOTH', $zstart, $boundary);
331
			foreach ($num as $values) {
332
				foreach ($values as $age_value) {
333
					fill_y_data($boundary, (int) ($age_value / 365.25), 1);
334
					$total++;
335
				}
336
			}
337
			$zstart = $boundary + 1;
338
		}
339
	}
340
341
	return $total;
342
}
343
344
/**
345
 * Age related to death year
@@ 353-394 (lines=42) @@
350
 *
351
 * @return int
352
 */
353
function lifespan_by_death_year($z_axis, array $z_boundaries, Stats $stats) {
354
	$total = 0;
355
356
	if ($z_axis === 300) {
357
		$num = $stats->statsAgeQuery(false, 'DEAT');
358
		foreach ($num as $values) {
359
			foreach ($values as $age_value) {
360
				fill_y_data(0, (int) ($age_value / 365.25), 1);
361
				$total++;
362
			}
363
		}
364
	} elseif ($z_axis === 301) {
365
		$num = $stats->statsAgeQuery(false, 'DEAT', 'M');
366
		foreach ($num as $values) {
367
			foreach ($values as $age_value) {
368
				fill_y_data(0, (int) ($age_value / 365.25), 1);
369
				$total++;
370
			}
371
		}
372
		$num = $stats->statsAgeQuery(false, 'DEAT', 'F');
373
		foreach ($num as $values) {
374
			foreach ($values as $age_value) {
375
				fill_y_data(1, (int) ($age_value / 365.25), 1);
376
				$total++;
377
			}
378
		}
379
	} else {
380
		$zstart = 0;
381
		foreach ($z_boundaries as $boundary) {
382
			$num = $stats->statsAgeQuery(false, 'DEAT', 'BOTH', $zstart, $boundary);
383
			foreach ($num as $values) {
384
				foreach ($values as $age_value) {
385
					fill_y_data($boundary, (int) ($age_value / 365.25), 1);
386
					$total++;
387
				}
388
			}
389
			$zstart = $boundary + 1;
390
		}
391
	}
392
393
	return $total;
394
}
395
396
/**
397
 * Age in year of marriage