Open Data Catalog v2.0.0
GetStringsFromStateMachineExecution.php
Go to the documentation of this file.
1 <?php
2 
4 
9  private $execution;
10  private $strings = [];
11  private $currentString = "";
12 
16  public function __construct(array $stateMachineExecution) {
17  $this->execution = $stateMachineExecution;
18  }
19 
23  public function get() {
24  foreach ($this->execution as $states_or_input) {
25  if ($this->isStates($states_or_input)) {
26  $this->processStates($states_or_input);
27  continue;
28  }
29 
30  $input = $states_or_input;
31  $this->currentString .= $input;
32  }
33 
34  $this->saveAndResetCurrentString();
35 
36  return $this->strings;
37  }
38 
42  private function processStates(array $states) {
43  if ($this->containsFirstState($states)) {
44  $this->saveAndResetCurrentString();
45  }
46  }
47 
51  private function saveAndResetCurrentString() {
52  if (!empty($this->currentString)) {
53  $this->strings[] = $this->currentString;
54  $this->currentString = "";
55  }
56  }
57 
61  private function isStates($input): bool {
62  return is_array($input);
63  }
64 
68  private function containsFirstState(array $states): bool {
69  return in_array(0, $states);
70  }
71 
72 }
Drupal\datastore\SqlEndpoint\Helper\GetStringsFromStateMachineExecution
Definition: GetStringsFromStateMachineExecution.php:8
Drupal\datastore\SqlEndpoint\Helper
Definition: GetStringsFromStateMachineExecution.php:3
Drupal\datastore\SqlEndpoint\Helper\GetStringsFromStateMachineExecution\__construct
__construct(array $stateMachineExecution)
Definition: GetStringsFromStateMachineExecution.php:16