phpstreams\Functions::identity PHP Method

identity() public static method

Get an identity function.
public static identity ( ) : callable
return callable A function that returns its first argument.
    public static function identity()
    {
        return function ($value) {
            return $value;
        };
    }

Usage Example

コード例 #1
0
ファイル: FunctionsTest.php プロジェクト: bertptrs/phpstreams
 /**
  * Test the Functions::identity method.
  */
 public function testIdentity()
 {
     $data = ['foo', 'bar', 42];
     $identityFunc = Functions::identity();
     $this->assertTrue(is_callable($identityFunc), "Identity function should be callable.");
     foreach ($data as $item) {
         $this->assertEquals($item, $identityFunc($item));
     }
 }
All Usage Examples Of phpstreams\Functions::identity