mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented test for 3 dimensions
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
trait MembersAttribut
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
protected $members;
|
||||
@@ -26,22 +28,27 @@ trait MembersAttribut
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dimension
|
||||
* The dimensions start with 1 for the members of the actuall dimension and NULL for all members
|
||||
* @param Collection $members
|
||||
* A reference to a members list, to which new members should be add
|
||||
*
|
||||
* @param int $dimension
|
||||
* The dimensions start with 1 for the members of the actuall dimension and NULL for all members
|
||||
* @param Collection $members
|
||||
* A reference to a members list, to which new members should be add
|
||||
*
|
||||
* @return Collection|MembersAttributInterface[] Returns all members till the defined dimension
|
||||
*/
|
||||
public function getMembersInclusiveChildren(?int $dimension = null, Collection $members = null): Collection
|
||||
{
|
||||
print_r('Hello '.$this.' ('.$dimension.')'.$members."\n");
|
||||
$dimension = is_int($dimension)?--$dimension:null;
|
||||
// print_r('Dimension:');
|
||||
// var_dump($dimension);
|
||||
$dimension = is_int($dimension) ? $dimension - 1: null;
|
||||
// var_dump($dimension);
|
||||
$members = $members ?? new ArrayCollection();
|
||||
// print_r('Hello ' . $this . ' (' . $dimension . ')' . $members->count() . "\n");
|
||||
foreach ($this->members->toArray() as $member) {
|
||||
if (!$members->contains($member)) {
|
||||
if (! $members->contains($member)) {
|
||||
$members->add($member);
|
||||
if ($this->continueIncludeMembersLoop($dimension)) {
|
||||
if ($dimension > 0) {
|
||||
var_dump($dimension);
|
||||
$member->getMembersInclusiveChildren($dimension, $members);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +56,8 @@ trait MembersAttribut
|
||||
return $members;
|
||||
}
|
||||
|
||||
private function continueIncludeMembersLoop(?int $dimension):bool{
|
||||
private function continueIncludeMembersLoop(?int $dimension): bool
|
||||
{
|
||||
return (is_null($dimension) || $dimension > 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user