ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\StudyProgramme\Assignment\Zipper Class Reference
+ Collaboration diagram for ILIAS\StudyProgramme\Assignment\Zipper:

Public Member Functions

 __construct (Node $focus)
 
 toChild (string $id)
 
 isTop ()
 
 toParent ()
 
 toPath (array $hops)
 
 getRoot ()
 
 modifyFocus (callable $f)
 
 modifyAll (callable $f, Zipper $zipper=null)
 

Protected Attributes

array $path = []
 

Detailed Description

Definition at line 23 of file Zipper.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\StudyProgramme\Assignment\Zipper::__construct ( Node  $focus)

Definition at line 31 of file Zipper.php.

32  {
33  $this->path[] = $focus;
34  }

Member Function Documentation

◆ getRoot()

ILIAS\StudyProgramme\Assignment\Zipper::getRoot ( )

Definition at line 69 of file Zipper.php.

References ILIAS\StudyProgramme\Assignment\Zipper\toParent().

69  : Node
70  {
71  if (count($this->path) == 1) {
72  return array_pop($this->path);
73  } else {
74  return $this->toParent()->getRoot();
75  }
76  }
+ Here is the call graph for this function:

◆ isTop()

ILIAS\StudyProgramme\Assignment\Zipper::isTop ( )

Definition at line 43 of file Zipper.php.

Referenced by updateParentProgresses().

43  : bool
44  {
45  return count($this->path) == 1;
46  }
+ Here is the caller graph for this function:

◆ modifyAll()

ILIAS\StudyProgramme\Assignment\Zipper::modifyAll ( callable  $f,
Zipper  $zipper = null 
)

Definition at line 87 of file Zipper.php.

References ILIAS\StudyProgramme\Assignment\Zipper\modifyFocus().

87  : Zipper
88  {
89  $zipper = $zipper ?? $this;
90  $zipper = $zipper->modifyFocus($f);
91  foreach (end($zipper->path)->getSubnodes() as $subnode) {
92  $zipper = $zipper
93  ->modifyAll($f, $zipper->toChild($subnode->getId()))
94  ->toParent();
95  }
96  return $zipper;
97  }
+ Here is the call graph for this function:

◆ modifyFocus()

ILIAS\StudyProgramme\Assignment\Zipper::modifyFocus ( callable  $f)

Definition at line 78 of file Zipper.php.

References Vendor\Package\$f.

Referenced by ILIAS\StudyProgramme\Assignment\Zipper\modifyAll().

78  : Zipper
79  {
80  $clone = clone $this;
81  $focus = array_pop($clone->path);
82  $new_focus = $f($focus);
83  $clone->path[] = $new_focus;
84  return $clone;
85  }
+ Here is the caller graph for this function:

◆ toChild()

ILIAS\StudyProgramme\Assignment\Zipper::toChild ( string  $id)

Definition at line 36 of file Zipper.php.

Referenced by ILIAS\StudyProgramme\Assignment\Zipper\toPath().

36  : Zipper
37  {
38  $clone = clone $this;
39  $clone->path[] = end($this->path)->getSubnode($id);
40  return $clone;
41  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ toParent()

ILIAS\StudyProgramme\Assignment\Zipper::toParent ( )

Definition at line 48 of file Zipper.php.

Referenced by ILIAS\StudyProgramme\Assignment\Zipper\getRoot(), and updateParentProgresses().

48  : Zipper
49  {
50  $clone = clone $this;
51  $last_node = array_pop($clone->path);
52  $parent = array_pop($clone->path);
53  $clone->path[] = $parent->withSubnode($last_node);
54 
55  return $clone;
56  }
+ Here is the caller graph for this function:

◆ toPath()

ILIAS\StudyProgramme\Assignment\Zipper::toPath ( array  $hops)

Definition at line 58 of file Zipper.php.

References ILIAS\Survey\Mode\getId(), and ILIAS\StudyProgramme\Assignment\Zipper\toChild().

58  : Zipper
59  {
60  $zipper = $this;
61  foreach ($hops as $hop) {
62  if ($hop != end($this->path)->getId()) {
63  $zipper = $zipper->toChild($hop);
64  }
65  }
66  return $zipper;
67  }
+ Here is the call graph for this function:

Field Documentation

◆ $path

array ILIAS\StudyProgramme\Assignment\Zipper::$path = []
protected

Definition at line 28 of file Zipper.php.


The documentation for this class was generated from the following file: