compose() public static method

composition is defined as the function h such that h(a) == A(B(a)) for each a.
public static compose ( $functionA, $functionB ) : callable
$functionA
$functionB
return callable
Esempio n. 1
0
 public function getFieldsAsString()
 {
     $fields = array_keys($this->_attributes);
     $escapedFields = Arrays::map($fields, Functions::compose(Functions::append("'"), Functions::prepend("'")));
     for ($index = self::FIELDS_COUNT_IN_LINE; $index < sizeof($escapedFields); $index += self::FIELDS_COUNT_IN_LINE) {
         $escapedFields[$index] = "\n\t\t\t" . $escapedFields[$index];
     }
     return implode(', ', $escapedFields);
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function shouldComposeFunctions()
 {
     //given
     $functionA = Functions::trim();
     $functionB = Functions::append('a ');
     //when
     $result = Functions::call(Functions::compose($functionA, $functionB), ' ');
     //then
     $this->assertEquals('a', $result);
 }