PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.11.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.11.0
2.11.0 2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 All 78 releases
fluent-community / vendor / wpfluent / framework / src / WPFluent / Support / Pipe.php

Pipe.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.11.0, at vendor/wpfluent/framework/src/WPFluent/Support/Pipe.php

68 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCommunity\Framework\Support;
4
5 /**
6 * @phpstan-consistent-constructor
7 */
8 class Pipe
9 {
10 use Tappable, Conditionable, MacroableTrait;
11
12 /**
13 * The value being piped.
14 *
15 * @var mixed
16 */
17 protected $value;
18
19 /**
20 * Create a new pipe instance.
21 *
22 * @param mixed $value
23 * @return void
24 */
25 public function __construct($value)
26 {
27 $this->value = $value;
28 }
29
30 /**
31 * Get a new pipe instance for the given value.
32 *
33 * @param mixed $value
34 * @return static
35 */
36 public static function of($value)
37 {
38 return new static($value);
39 }
40
41 /**
42 * Pass the value to the callback and return a new pipe for the result.
43 *
44 * Any extra arguments are passed to the callback after the value.
45 *
46 * @param callable $callback
47 * @param mixed ...$args
48 * @return static
49 */
50 public function pipe(callable $callback, ...$args)
51 {
52 // A copy, so by-reference callbacks like sort() can't change this pipe.
53 $value = $this->value;
54
55 return new static($callback($value, ...$args));
56 }
57
58 /**
59 * Get the piped value.
60 *
61 * @return mixed
62 */
63 public function value()
64 {
65 return $this->value;
66 }
67 }
68