public function select() { if ($this->_query->type == QueryType::$SELECT) { return 'SELECT ' . ($this->_query->distinct ? 'DISTINCT ' : '') . (empty($this->_query->selectColumns) ? '*' : Joiner::on(', ')->map(DialectUtil::_addAliases())->join($this->_query->selectColumns)); } if ($this->_query->type == QueryType::$COUNT) { return 'SELECT count(*)'; } return ''; }
private function _generateFunctions() { $namesAlreadyGenerated = array(); foreach ($this->_routes as $route) { if (!in_array($route->getName(), $namesAlreadyGenerated)) { $this->_generatedFunctions .= $this->_createFunction($route); } $namesAlreadyGenerated[] = $route->getName(); } $names = Joiner::on(",\n%{INDENT}%{INDENT}")->skipNulls()->mapValues(function ($value) { return "'{$value}'"; })->join($namesAlreadyGenerated); $this->_generatedFunctions .= "function allGeneratedUriNames()\n{\n%{INDENT}return array(" . $names . ");\n}\n\n"; }
private static function getParameterDeclaration(ReflectionFunctionAbstract $method) { return Joiner::on(', ')->join(Arrays::map($method->getParameters(), function (ReflectionParameter $param) { $result = ''; if ($param->getClass()) { $result .= $param->getClass()->getName() . ' '; } if ($param->isArray()) { $result .= 'array '; } if ($param->isPassedByReference()) { $result .= '&'; } $result .= '$' . $param->name; if ($param->isDefaultValueAvailable()) { $result .= " = null"; // methodHandler gets only the passed arguments so anything would work here } return $result; })); }
public static function prepare(array $whereClauses = array()) { $where = Joiner::on(' AND ')->mapValues(Functions::extract()->getWhere())->join($whereClauses); return new self($where); }
public function getOriginalMessage() { return Joiner::on(', ')->map(function ($key, $value) { return $value->originalMessage; })->join($this->_errors); }
/** * @test */ public function shouldJoinMapApplyingFunctionOnValues() { //when $result = Joiner::on(', ')->mapValues(function ($value) { return "val = {$value}"; })->join(array(1 => 'A', 2 => 'B', 3 => 'C')); //then $this->assertEquals('val = A, val = B, val = C', $result); }
private static function _mergeParams(array $params) { return '/' . Joiner::on('/')->map(function ($key, $value) { return $key . '/' . $value; })->join($params); }
private function _mergeAttributes($attributes, $options) { if (isset($options['class']) && isset($attributes['class'])) { $options['class'] = Joiner::on(' ')->skipNulls()->join(array($options['class'], $attributes['class'])); } return array_merge($attributes, $options); }
public static function arrayToString($calls) { return Joiner::on(', ')->join(Arrays::map($calls, Functions::toString())); }
public static function buildAttributesPartForUpdate($updateAttributes) { return Joiner::on(', ')->join(FluentArray::from($updateAttributes)->keys()->map(function ($column) { return "{$column} = ?"; })->toArray()); }