Skip to content

Commit ebcf09d

Browse files
author
Marc Aschmann
committed
Add method chaining to examples
1 parent 05477f7 commit ebcf09d

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

lib/PhpFlo/Component/Counter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ public function appendCount($data)
4949

5050
public function sendCount()
5151
{
52-
$this->outPorts()->count->send($this->count);
53-
$this->outPorts()->count->disconnect();
52+
$this->outPorts()
53+
->count
54+
->send($this->count)
55+
->disconnect();
56+
5457
$this->count = null;
5558
}
5659
}

lib/PhpFlo/Component/Queue.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ public function __construct()
4242
$this->size = 100;
4343
$this->messages = [];
4444

45-
$this->inPorts()->add('in', ['datatype' => 'all']);
46-
$this->inPorts()->add('size', ['datatype' => 'all']);
45+
$this->inPorts()
46+
->add('in', ['datatype' => 'all'])
47+
->add('size', ['datatype' => 'all']);
4748

48-
$this->outPorts()->add('error', ['datatype' => 'all']);
49-
$this->outPorts()->add('messages', ['datatype' => 'all']);
49+
$this->outPorts()
50+
->add('error', ['datatype' => 'all'])
51+
->add('messages', ['datatype' => 'all']);
5052

5153
$this->inPorts()->in->on('data', [$this, 'onAppendQueue']);
5254
$this->inPorts()->in->on('detach', [$this, 'onStreamEnded']);
@@ -96,8 +98,10 @@ private function sendQueue()
9698

9799
private function flushQueue()
98100
{
99-
$this->outPorts()->messages->send($this->messages);
100-
$this->outPorts()->messages->disconnect();
101+
$this->outPorts()
102+
->messages
103+
->send($this->messages)
104+
->disconnect();
101105

102106
$this->messages = [];
103107
}

lib/PhpFlo/Component/ReadFile.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ class ReadFile extends Component
2323
public function __construct()
2424
{
2525
$this->inPorts()->add('source', ['datatype' => 'string']);
26-
$this->outPorts()->add('out', ['datatype' => 'string']);
27-
$this->outPorts()->add('error', []); // use defaults, datatype = all
26+
$this->outPorts()
27+
->add('out', ['datatype' => 'string'])
28+
->add('error', []); // use defaults, datatype = all
2829

2930
$this->inPorts()->source->on('data', [$this, 'readFile']);
3031
}
@@ -40,7 +41,9 @@ public function readFile($data)
4041
return;
4142
}
4243

43-
$this->outPorts()->out->send(file_get_contents($data));
44-
$this->outPorts()->out->disconnect();
44+
$this->outPorts()
45+
->out
46+
->send(file_get_contents($data))
47+
->disconnect();
4548
}
4649
}

lib/PhpFlo/Component/SplitStr.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ class SplitStr extends Component
3232

3333
public function __construct()
3434
{
35-
$this->inPorts()->add('in', ['datatype' => 'string']);
36-
$this->inPorts()->add('delimiter', ['datatype' => 'string']);
35+
$this->inPorts()
36+
->add('in', ['datatype' => 'string'])
37+
->add('delimiter', ['datatype' => 'string']);
3738
$this->outPorts()->add('out', ['datatype' => 'string']);
3839

3940
$this->inPorts()->delimiter->on('data', [$this, 'setDelimiter']);

0 commit comments

Comments
 (0)