| Conditions | 106 | 
| Paths | 124 | 
| Total Lines | 521 | 
| Code Lines | 401 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 250 | public function postCustomChartAction(ServerRequestInterface $request): ResponseInterface | ||
| 251 |     { | ||
| 252 | $statistics = app(Statistics::class); | ||
| 253 | |||
| 254 | $params = $request->getParsedBody(); | ||
| 255 | |||
| 256 | $x_axis_type = (int) $params['x-as']; | ||
| 257 | $y_axis_type = (int) $params['y-as']; | ||
| 258 | $z_axis_type = (int) $params['z-as']; | ||
| 259 | $ydata = []; | ||
| 260 | |||
| 261 |         switch ($x_axis_type) { | ||
| 262 | case self::X_AXIS_INDIVIDUAL_MAP: | ||
| 263 | return response($statistics->chartDistribution( | ||
| 264 | $params['chart_shows'], | ||
| 265 | $params['chart_type'], | ||
| 266 | $params['SURN'] | ||
| 267 | )); | ||
| 268 | |||
| 269 | case self::X_AXIS_BIRTH_MAP: | ||
| 270 | return response($statistics->chartDistribution( | ||
| 271 | $params['chart_shows'], | ||
| 272 | 'birth_distribution_chart' | ||
| 273 | )); | ||
| 274 | |||
| 275 | case self::X_AXIS_DEATH_MAP: | ||
| 276 | return response($statistics->chartDistribution( | ||
| 277 | $params['chart_shows'], | ||
| 278 | 'death_distribution_chart' | ||
| 279 | )); | ||
| 280 | |||
| 281 | case self::X_AXIS_MARRIAGE_MAP: | ||
| 282 | return response($statistics->chartDistribution( | ||
| 283 | $params['chart_shows'], | ||
| 284 | 'marriage_distribution_chart' | ||
| 285 | )); | ||
| 286 | |||
| 287 | case self::X_AXIS_BIRTH_MONTH: | ||
| 288 |                 $chart_title  = I18N::translate('Month of birth'); | ||
| 289 |                 $x_axis_title = I18N::translate('Month'); | ||
| 290 | $x_axis = $this->axisMonths(); | ||
| 291 | |||
| 292 |                 switch ($y_axis_type) { | ||
| 293 | case self::Y_AXIS_NUMBERS: | ||
| 294 |                         $y_axis_title = I18N::translate('Individuals'); | ||
| 295 | break; | ||
| 296 | case self::Y_AXIS_PERCENT: | ||
| 297 | $y_axis_title = '%'; | ||
| 298 | break; | ||
| 299 | default: | ||
| 300 | throw new NotFoundHttpException(); | ||
| 301 | } | ||
| 302 | |||
| 303 |                 switch ($z_axis_type) { | ||
| 304 | case self::Z_AXIS_ALL: | ||
| 305 | $z_axis = $this->axisAll(); | ||
| 306 | $rows = $statistics->statsBirthQuery()->get(); | ||
| 307 |                         foreach ($rows as $row) { | ||
| 308 | $this->fillYData($row->d_month, 0, $row->total, $x_axis, $z_axis, $ydata); | ||
| 309 | } | ||
| 310 | break; | ||
| 311 | case self::Z_AXIS_SEX: | ||
| 312 | $z_axis = $this->axisSexes(); | ||
| 313 | $rows = $statistics->statsBirthBySexQuery()->get(); | ||
| 314 |                         foreach ($rows as $row) { | ||
| 315 | $this->fillYData($row->d_month, $row->i_sex, $row->total, $x_axis, $z_axis, $ydata); | ||
| 316 | } | ||
| 317 | break; | ||
| 318 | case self::Z_AXIS_TIME: | ||
| 319 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 320 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 321 | $prev_boundary = 0; | ||
| 322 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 323 | $rows = $statistics->statsBirthQuery($prev_boundary, $boundary)->get(); | ||
| 324 |                             foreach ($rows as $row) { | ||
| 325 | $this->fillYData($row->d_month, $boundary, $row->total, $x_axis, $z_axis, $ydata); | ||
| 326 | } | ||
| 327 | $prev_boundary = $boundary + 1; | ||
| 328 | } | ||
| 329 | break; | ||
| 330 | default: | ||
| 331 | throw new NotFoundHttpException(); | ||
| 332 | } | ||
| 333 | |||
| 334 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 335 | |||
| 336 | case self::X_AXIS_DEATH_MONTH: | ||
| 337 |                 $chart_title  = I18N::translate('Month of death'); | ||
| 338 |                 $x_axis_title = I18N::translate('Month'); | ||
| 339 | $x_axis = $this->axisMonths(); | ||
| 340 | |||
| 341 |                 switch ($y_axis_type) { | ||
| 342 | case self::Y_AXIS_NUMBERS: | ||
| 343 |                         $y_axis_title = I18N::translate('Individuals'); | ||
| 344 | break; | ||
| 345 | case self::Y_AXIS_PERCENT: | ||
| 346 | $y_axis_title = '%'; | ||
| 347 | break; | ||
| 348 | default: | ||
| 349 | throw new NotFoundHttpException(); | ||
| 350 | } | ||
| 351 | |||
| 352 |                 switch ($z_axis_type) { | ||
| 353 | case self::Z_AXIS_ALL: | ||
| 354 | $z_axis = $this->axisAll(); | ||
| 355 | $rows = $statistics->statsDeathQuery()->get(); | ||
| 356 |                         foreach ($rows as $row) { | ||
| 357 | $this->fillYData($row->d_month, 0, $row->total, $x_axis, $z_axis, $ydata); | ||
| 358 | } | ||
| 359 | break; | ||
| 360 | case self::Z_AXIS_SEX: | ||
| 361 | $z_axis = $this->axisSexes(); | ||
| 362 | $rows = $statistics->statsDeathBySexQuery()->get(); | ||
| 363 |                         foreach ($rows as $row) { | ||
| 364 | $this->fillYData($row->d_month, $row->i_sex, $row->total, $x_axis, $z_axis, $ydata); | ||
| 365 | } | ||
| 366 | break; | ||
| 367 | case self::Z_AXIS_TIME: | ||
| 368 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 369 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 370 | $prev_boundary = 0; | ||
| 371 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 372 | $rows = $statistics->statsDeathQuery($prev_boundary, $boundary)->get(); | ||
| 373 |                             foreach ($rows as $row) { | ||
| 374 | $this->fillYData($row->d_month, $boundary, $row->total, $x_axis, $z_axis, $ydata); | ||
| 375 | } | ||
| 376 | $prev_boundary = $boundary + 1; | ||
| 377 | } | ||
| 378 | break; | ||
| 379 | default: | ||
| 380 | throw new NotFoundHttpException(); | ||
| 381 | } | ||
| 382 | |||
| 383 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 384 | |||
| 385 | case self::X_AXIS_MARRIAGE_MONTH: | ||
| 386 |                 $chart_title  = I18N::translate('Month of marriage'); | ||
| 387 |                 $x_axis_title = I18N::translate('Month'); | ||
| 388 | $x_axis = $this->axisMonths(); | ||
| 389 | |||
| 390 |                 switch ($y_axis_type) { | ||
| 391 | case self::Y_AXIS_NUMBERS: | ||
| 392 |                         $y_axis_title = I18N::translate('Families'); | ||
| 393 | break; | ||
| 394 | case self::Y_AXIS_PERCENT: | ||
| 395 | $y_axis_title = '%'; | ||
| 396 | break; | ||
| 397 | default: | ||
| 398 | throw new NotFoundHttpException(); | ||
| 399 | } | ||
| 400 | |||
| 401 |                 switch ($z_axis_type) { | ||
| 402 | case self::Z_AXIS_ALL: | ||
| 403 | $z_axis = $this->axisAll(); | ||
| 404 | $rows = $statistics->statsMarriageQuery()->get(); | ||
| 405 |                         foreach ($rows as $row) { | ||
| 406 | $this->fillYData($row->d_month, 0, $row->total, $x_axis, $z_axis, $ydata); | ||
| 407 | } | ||
| 408 | break; | ||
| 409 | case self::Z_AXIS_TIME: | ||
| 410 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 411 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 412 | $prev_boundary = 0; | ||
| 413 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 414 | $rows = $statistics->statsMarriageQuery($prev_boundary, $boundary)->get(); | ||
| 415 |                             foreach ($rows as $row) { | ||
| 416 | $this->fillYData($row->d_month, $boundary, $row->total, $x_axis, $z_axis, $ydata); | ||
| 417 | } | ||
| 418 | $prev_boundary = $boundary + 1; | ||
| 419 | } | ||
| 420 | break; | ||
| 421 | default: | ||
| 422 | throw new NotFoundHttpException(); | ||
| 423 | } | ||
| 424 | |||
| 425 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 426 | |||
| 427 | case self::X_AXIS_FIRST_CHILD_MONTH: | ||
| 428 |                 $chart_title  = I18N::translate('Month of birth of first child in a relation'); | ||
| 429 |                 $x_axis_title = I18N::translate('Month'); | ||
| 430 | $x_axis = $this->axisMonths(); | ||
| 431 | |||
| 432 |                 switch ($y_axis_type) { | ||
| 433 | case self::Y_AXIS_NUMBERS: | ||
| 434 |                         $y_axis_title = I18N::translate('Children'); | ||
| 435 | break; | ||
| 436 | case self::Y_AXIS_PERCENT: | ||
| 437 | $y_axis_title = '%'; | ||
| 438 | break; | ||
| 439 | default: | ||
| 440 | throw new NotFoundHttpException(); | ||
| 441 | } | ||
| 442 | |||
| 443 |                 switch ($z_axis_type) { | ||
| 444 | case self::Z_AXIS_ALL: | ||
| 445 | $z_axis = $this->axisAll(); | ||
| 446 | $rows = $statistics->monthFirstChildQuery()->get(); | ||
| 447 |                         foreach ($rows as $row) { | ||
| 448 | $this->fillYData($row->d_month, 0, $row->total, $x_axis, $z_axis, $ydata); | ||
| 449 | } | ||
| 450 | break; | ||
| 451 | case self::Z_AXIS_SEX: | ||
| 452 | $z_axis = $this->axisSexes(); | ||
| 453 | $rows = $statistics->monthFirstChildBySexQuery()->get(); | ||
| 454 |                         foreach ($rows as $row) { | ||
| 455 | $this->fillYData($row->d_month, $row->i_sex, $row->total, $x_axis, $z_axis, $ydata); | ||
| 456 | } | ||
| 457 | break; | ||
| 458 | case self::Z_AXIS_TIME: | ||
| 459 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 460 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 461 | $prev_boundary = 0; | ||
| 462 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 463 | $rows = $statistics->monthFirstChildQuery($prev_boundary, $boundary)->get(); | ||
| 464 |                             foreach ($rows as $row) { | ||
| 465 | $this->fillYData($row->d_month, $boundary, $row->total, $x_axis, $z_axis, $ydata); | ||
| 466 | } | ||
| 467 | $prev_boundary = $boundary + 1; | ||
| 468 | } | ||
| 469 | break; | ||
| 470 | default: | ||
| 471 | throw new NotFoundHttpException(); | ||
| 472 | } | ||
| 473 | |||
| 474 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 475 | |||
| 476 | case self::X_AXIS_FIRST_MARRIAGE_MONTH: | ||
| 477 |                 $chart_title  = I18N::translate('Month of first marriage'); | ||
| 478 |                 $x_axis_title = I18N::translate('Month'); | ||
| 479 | $x_axis = $this->axisMonths(); | ||
| 480 | |||
| 481 |                 switch ($y_axis_type) { | ||
| 482 | case self::Y_AXIS_NUMBERS: | ||
| 483 |                         $y_axis_title = I18N::translate('Families'); | ||
| 484 | break; | ||
| 485 | case self::Y_AXIS_PERCENT: | ||
| 486 | $y_axis_title = '%'; | ||
| 487 | break; | ||
| 488 | default: | ||
| 489 | throw new NotFoundHttpException(); | ||
| 490 | } | ||
| 491 | |||
| 492 |                 switch ($z_axis_type) { | ||
| 493 | case self::Z_AXIS_ALL: | ||
| 494 | $z_axis = $this->axisAll(); | ||
| 495 | $rows = $statistics->statsFirstMarriageQuery()->get(); | ||
| 496 | $indi = []; | ||
| 497 | $fam = []; | ||
| 498 |                         foreach ($rows as $row) { | ||
| 499 |                             if (!in_array($row->indi, $indi, true) && !in_array($row->fams, $fam, true)) { | ||
| 500 | $this->fillYData($row->month, 0, 1, $x_axis, $z_axis, $ydata); | ||
| 501 | } | ||
| 502 | $indi[] = $row->indi; | ||
| 503 | $fam[] = $row->fams; | ||
| 504 | } | ||
| 505 | break; | ||
| 506 | case self::Z_AXIS_TIME: | ||
| 507 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 508 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 509 | $prev_boundary = 0; | ||
| 510 | $indi = []; | ||
| 511 | $fam = []; | ||
| 512 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 513 | $rows = $statistics->statsFirstMarriageQuery($prev_boundary, $boundary)->get(); | ||
| 514 |                             foreach ($rows as $row) { | ||
| 515 |                                 if (!in_array($row->indi, $indi, true) && !in_array($row->fams, $fam, true)) { | ||
| 516 | $this->fillYData($row->month, $boundary, 1, $x_axis, $z_axis, $ydata); | ||
| 517 | } | ||
| 518 | $indi[] = $row->indi; | ||
| 519 | $fam[] = $row->fams; | ||
| 520 | } | ||
| 521 | $prev_boundary = $boundary + 1; | ||
| 522 | } | ||
| 523 | break; | ||
| 524 | default: | ||
| 525 | throw new NotFoundHttpException(); | ||
| 526 | } | ||
| 527 | |||
| 528 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 529 | |||
| 530 | case self::X_AXIS_AGE_AT_DEATH: | ||
| 531 |                 $chart_title    = I18N::translate('Average age at death'); | ||
| 532 |                 $x_axis_title   = I18N::translate('age'); | ||
| 533 | $boundaries_csv = $params['x-axis-boundaries-ages']; | ||
| 534 | $x_axis = $this->axisNumbers($boundaries_csv); | ||
| 535 | |||
| 536 |                 switch ($y_axis_type) { | ||
| 537 | case self::Y_AXIS_NUMBERS: | ||
| 538 |                         $y_axis_title = I18N::translate('Individuals'); | ||
| 539 | break; | ||
| 540 | case self::Y_AXIS_PERCENT: | ||
| 541 | $y_axis_title = '%'; | ||
| 542 | break; | ||
| 543 | default: | ||
| 544 | throw new NotFoundHttpException(); | ||
| 545 | } | ||
| 546 | |||
| 547 |                 switch ($z_axis_type) { | ||
| 548 | case self::Z_AXIS_ALL: | ||
| 549 | $z_axis = $this->axisAll(); | ||
| 550 |                         $rows   = $statistics->statsAgeQuery('DEAT'); | ||
| 551 |                         foreach ($rows as $row) { | ||
| 552 |                             foreach ($row as $age) { | ||
| 553 | $years = (int) ($age / self::DAYS_IN_YEAR); | ||
| 554 | $this->fillYData($years, 0, 1, $x_axis, $z_axis, $ydata); | ||
| 555 | } | ||
| 556 | } | ||
| 557 | break; | ||
| 558 | case self::Z_AXIS_SEX: | ||
| 559 | $z_axis = $this->axisSexes(); | ||
| 560 |                         foreach (array_keys($z_axis) as $sex) { | ||
| 561 |                             $rows = $statistics->statsAgeQuery('DEAT', $sex); | ||
| 562 |                             foreach ($rows as $row) { | ||
| 563 |                                 foreach ($row as $age) { | ||
| 564 | $years = (int) ($age / self::DAYS_IN_YEAR); | ||
| 565 | $this->fillYData($years, $sex, 1, $x_axis, $z_axis, $ydata); | ||
| 566 | } | ||
| 567 | } | ||
| 568 | } | ||
| 569 | break; | ||
| 570 | case self::Z_AXIS_TIME: | ||
| 571 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 572 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 573 | $prev_boundary = 0; | ||
| 574 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 575 |                             $rows = $statistics->statsAgeQuery('DEAT', 'BOTH', $prev_boundary, $boundary); | ||
| 576 |                             foreach ($rows as $row) { | ||
| 577 |                                 foreach ($row as $age) { | ||
| 578 | $years = (int) ($age / self::DAYS_IN_YEAR); | ||
| 579 | $this->fillYData($years, $boundary, 1, $x_axis, $z_axis, $ydata); | ||
| 580 | } | ||
| 581 | } | ||
| 582 | $prev_boundary = $boundary + 1; | ||
| 583 | } | ||
| 584 | |||
| 585 | break; | ||
| 586 | default: | ||
| 587 | throw new NotFoundHttpException(); | ||
| 588 | } | ||
| 589 | |||
| 590 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 591 | |||
| 592 | case self::X_AXIS_AGE_AT_MARRIAGE: | ||
| 593 |                 $chart_title    = I18N::translate('Age in year of marriage'); | ||
| 594 |                 $x_axis_title   = I18N::translate('age'); | ||
| 595 | $boundaries_csv = $params['x-axis-boundaries-ages_m']; | ||
| 596 | $x_axis = $this->axisNumbers($boundaries_csv); | ||
| 597 | |||
| 598 |                 switch ($y_axis_type) { | ||
| 599 | case self::Y_AXIS_NUMBERS: | ||
| 600 |                         $y_axis_title = I18N::translate('Individuals'); | ||
| 601 | break; | ||
| 602 | case self::Y_AXIS_PERCENT: | ||
| 603 | $y_axis_title = '%'; | ||
| 604 | break; | ||
| 605 | default: | ||
| 606 | throw new NotFoundHttpException(); | ||
| 607 | } | ||
| 608 | |||
| 609 |                 switch ($z_axis_type) { | ||
| 610 | case self::Z_AXIS_ALL: | ||
| 611 | $z_axis = $this->axisAll(); | ||
| 612 | // The stats query doesn't have an "all" function, so query M/F separately | ||
| 613 |                         foreach (['M', 'F'] as $sex) { | ||
| 614 | $rows = $statistics->statsMarrAgeQuery($sex); | ||
| 615 |                             foreach ($rows as $row) { | ||
| 616 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 617 | $this->fillYData($years, 0, 1, $x_axis, $z_axis, $ydata); | ||
| 618 | } | ||
| 619 | } | ||
| 620 | break; | ||
| 621 | case self::Z_AXIS_SEX: | ||
| 622 | $z_axis = $this->axisSexes(); | ||
| 623 |                         foreach (array_keys($z_axis) as $sex) { | ||
| 624 | $rows = $statistics->statsMarrAgeQuery($sex); | ||
| 625 |                             foreach ($rows as $row) { | ||
| 626 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 627 | $this->fillYData($years, $sex, 1, $x_axis, $z_axis, $ydata); | ||
| 628 | } | ||
| 629 | } | ||
| 630 | break; | ||
| 631 | case self::Z_AXIS_TIME: | ||
| 632 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 633 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 634 | // The stats query doesn't have an "all" function, so query M/F separately | ||
| 635 |                         foreach (['M', 'F'] as $sex) { | ||
| 636 | $prev_boundary = 0; | ||
| 637 |                             foreach (array_keys($z_axis) as $boundary) { | ||
| 638 | $rows = $statistics->statsMarrAgeQuery($sex, $prev_boundary, $boundary); | ||
| 639 |                                 foreach ($rows as $row) { | ||
| 640 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 641 | $this->fillYData($years, $boundary, 1, $x_axis, $z_axis, $ydata); | ||
| 642 | } | ||
| 643 | $prev_boundary = $boundary + 1; | ||
| 644 | } | ||
| 645 | } | ||
| 646 | break; | ||
| 647 | default: | ||
| 648 | throw new NotFoundHttpException(); | ||
| 649 | } | ||
| 650 | |||
| 651 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 652 | |||
| 653 | case self::X_AXIS_AGE_AT_FIRST_MARRIAGE: | ||
| 654 |                 $chart_title    = I18N::translate('Age in year of first marriage'); | ||
| 655 |                 $x_axis_title   = I18N::translate('age'); | ||
| 656 | $boundaries_csv = $params['x-axis-boundaries-ages_m']; | ||
| 657 | $x_axis = $this->axisNumbers($boundaries_csv); | ||
| 658 | |||
| 659 |                 switch ($y_axis_type) { | ||
| 660 | case self::Y_AXIS_NUMBERS: | ||
| 661 |                         $y_axis_title = I18N::translate('Individuals'); | ||
| 662 | break; | ||
| 663 | case self::Y_AXIS_PERCENT: | ||
| 664 | $y_axis_title = '%'; | ||
| 665 | break; | ||
| 666 | default: | ||
| 667 | throw new NotFoundHttpException(); | ||
| 668 | } | ||
| 669 | |||
| 670 |                 switch ($z_axis_type) { | ||
| 671 | case self::Z_AXIS_ALL: | ||
| 672 | $z_axis = $this->axisAll(); | ||
| 673 | // The stats query doesn't have an "all" function, so query M/F separately | ||
| 674 |                         foreach (['M', 'F'] as $sex) { | ||
| 675 | $rows = $statistics->statsMarrAgeQuery($sex); | ||
| 676 | $indi = []; | ||
| 677 |                             foreach ($rows as $row) { | ||
| 678 |                                 if (!in_array($row->d_gid, $indi, true)) { | ||
| 679 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 680 | $this->fillYData($years, 0, 1, $x_axis, $z_axis, $ydata); | ||
| 681 | $indi[] = $row->d_gid; | ||
| 682 | } | ||
| 683 | } | ||
| 684 | } | ||
| 685 | break; | ||
| 686 | case self::Z_AXIS_SEX: | ||
| 687 | $z_axis = $this->axisSexes(); | ||
| 688 |                         foreach (array_keys($z_axis) as $sex) { | ||
| 689 | $rows = $statistics->statsMarrAgeQuery($sex); | ||
| 690 | $indi = []; | ||
| 691 |                             foreach ($rows as $row) { | ||
| 692 |                                 if (!in_array($row->d_gid, $indi, true)) { | ||
| 693 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 694 | $this->fillYData($years, $sex, 1, $x_axis, $z_axis, $ydata); | ||
| 695 | $indi[] = $row->d_gid; | ||
| 696 | } | ||
| 697 | } | ||
| 698 | } | ||
| 699 | break; | ||
| 700 | case self::Z_AXIS_TIME: | ||
| 701 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 702 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 703 | // The stats query doesn't have an "all" function, so query M/F separately | ||
| 704 |                         foreach (['M', 'F'] as $sex) { | ||
| 705 | $prev_boundary = 0; | ||
| 706 | $indi = []; | ||
| 707 |                             foreach (array_keys($z_axis) as $boundary) { | ||
| 708 | $rows = $statistics->statsMarrAgeQuery($sex, $prev_boundary, $boundary); | ||
| 709 |                                 foreach ($rows as $row) { | ||
| 710 |                                     if (!in_array($row->d_gid, $indi, true)) { | ||
| 711 | $years = (int) ($row->age / self::DAYS_IN_YEAR); | ||
| 712 | $this->fillYData($years, $boundary, 1, $x_axis, $z_axis, $ydata); | ||
| 713 | $indi[] = $row->d_gid; | ||
| 714 | } | ||
| 715 | } | ||
| 716 | $prev_boundary = $boundary + 1; | ||
| 717 | } | ||
| 718 | } | ||
| 719 | break; | ||
| 720 | default: | ||
| 721 | throw new NotFoundHttpException(); | ||
| 722 | } | ||
| 723 | |||
| 724 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 725 | |||
| 726 | case self::X_AXIS_NUMBER_OF_CHILDREN: | ||
| 727 |                 $chart_title  = I18N::translate('Number of children'); | ||
| 728 |                 $x_axis_title = I18N::translate('Children'); | ||
| 729 |                 $x_axis       = $this->axisNumbers('0,1,2,3,4,5,6,7,8,9,10'); | ||
| 730 | |||
| 731 |                 switch ($y_axis_type) { | ||
| 732 | case self::Y_AXIS_NUMBERS: | ||
| 733 |                         $y_axis_title = I18N::translate('Families'); | ||
| 734 | break; | ||
| 735 | case self::Y_AXIS_PERCENT: | ||
| 736 | $y_axis_title = '%'; | ||
| 737 | break; | ||
| 738 | default: | ||
| 739 | throw new NotFoundHttpException(); | ||
| 740 | } | ||
| 741 | |||
| 742 |                 switch ($z_axis_type) { | ||
| 743 | case self::Z_AXIS_ALL: | ||
| 744 | $z_axis = $this->axisAll(); | ||
| 745 | $rows = $statistics->statsChildrenQuery(); | ||
| 746 |                         foreach ($rows as $row) { | ||
| 747 | $this->fillYData($row->f_numchil, 0, $row->total, $x_axis, $z_axis, $ydata); | ||
| 748 | } | ||
| 749 | break; | ||
| 750 | case self::Z_AXIS_TIME: | ||
| 751 | $boundaries_csv = $params['z-axis-boundaries-periods']; | ||
| 752 | $z_axis = $this->axisYears($boundaries_csv); | ||
| 753 | $prev_boundary = 0; | ||
| 754 |                         foreach (array_keys($z_axis) as $boundary) { | ||
| 755 | $rows = $statistics->statsChildrenQuery($prev_boundary, $boundary); | ||
| 756 |                             foreach ($rows as $row) { | ||
| 757 | $this->fillYData($row->f_numchil, $boundary, $row->total, $x_axis, $z_axis, $ydata); | ||
| 758 | } | ||
| 759 | $prev_boundary = $boundary + 1; | ||
| 760 | } | ||
| 761 | break; | ||
| 762 | default: | ||
| 763 | throw new NotFoundHttpException(); | ||
| 764 | } | ||
| 765 | |||
| 766 | return response($this->myPlot($chart_title, $x_axis, $x_axis_title, $ydata, $y_axis_title, $z_axis, $y_axis_type)); | ||
| 767 | |||
| 768 | default: | ||
| 769 | throw new NotFoundHttpException(); | ||
| 770 | break; | ||
| 771 | } | ||
| 1053 | 
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.