本文整理汇总了PHP中Ouzo\Utilities\Arrays::map方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::map方法的具体用法?PHP Arrays::map怎么用?PHP Arrays::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ouzo\Utilities\Arrays
的用法示例。
在下文中一共展示了Arrays::map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareParameters
private function _prepareParameters($uri)
{
preg_match_all('#:(\\w+)#', $uri, $matches);
$parameters = Arrays::getValue($matches, 1, array());
return Arrays::map($parameters, function ($parameter) {
return '$' . $parameter;
});
}
示例2: whereWithUsing
private function whereWithUsing()
{
$usingClauses = $this->_query->usingClauses;
$whereClauses = Arrays::map($usingClauses, function (JoinClause $usingClause) {
return WhereClause::create($usingClause->getJoinColumnWithTable() . ' = ' . $usingClause->getJoinedColumnWithTable());
});
return $this->_where(array_merge($whereClauses, $this->_query->whereClauses));
}
示例3: contents
public function contents()
{
$this->_setupTablePlaceholderReplacements();
$this->classStub->addPlaceholderReplacement('class', $this->className);
$this->classStub->addPlaceholderReplacement('namespace', $this->classNamespace);
Arrays::map($this->tableInfo->tableColumns, array($this->classStub, 'addColumn'));
return $this->classStub->contents();
}
示例4: compareBy
/**
* Returns comparator which compares objects by using values computed using given expressions.
* Expressions should comply with format accepted by <code>Functions::extractExpression</code>.
* Comparator returns an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
*
* @param mixed ...
* @return callable
*/
public static function compareBy()
{
$expressions = func_get_args();
$comparators = Arrays::map($expressions, function ($expression) {
return new EvaluatingComparator(Functions::extractExpression($expression));
});
return sizeof($comparators) == 1 ? $comparators[0] : new CompoundComparator($comparators);
}
示例5: extractParams
private static function extractParams($elements)
{
$params = array();
foreach ($elements as $element) {
list($name, $value) = Arrays::map(explode('=', $element), Functions::trim());
$params[$name] = $value;
}
return $params;
}
示例6: parse
public function parse()
{
if (preg_match('/^findBy([a-zA-Z]\\w*)$/', $this->method, $names)) {
$names = explode('And', $names[1]);
$this->names = Arrays::map($names, function ($name) {
return Strings::camelCaseToUnderscore($name);
});
}
}
示例7: getFieldsAsString
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);
}
示例8: createCheckParameters
private function createCheckParameters($parameters)
{
if ($parameters) {
$indent = self::INDENT;
$checkFunctionParameters = Arrays::map($parameters, function ($element) use($indent) {
return $indent . "checkParameter({$element});";
});
return implode("\n", $checkFunctionParameters) . "\n" . $indent;
}
return self::INDENT;
}
示例9: _fetchRelations
private function _fetchRelations($results, $joinsToStore)
{
$joinedRelations = Arrays::map($joinsToStore, Functions::extract()->destinationField());
foreach ($this->relationsToFetch as $relationToFetch) {
if (!in_array($relationToFetch->destinationField, $joinedRelations)) {
$relationFetcher = new RelationFetcher($relationToFetch->relation);
$fieldTransformer = new FieldTransformer($relationToFetch->field, $relationFetcher);
$fieldTransformer->transform($results);
}
}
return $results;
}
示例10: _parseArgs
private function _parseArgs($args, $parameters)
{
$args = Arrays::getValue($args, 0, new stdClass());
$newArgs = array();
$parameterNames = Arrays::map($parameters, Functions::extract()->getName());
foreach ($parameterNames as $name) {
if (isset($args->{$name})) {
$newArgs[] = $args->{$name};
}
}
return $newArgs;
}
示例11: getParameterDeclaration
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;
}));
}
示例12: poll
public function poll()
{
Stats::reset();
session_write_close();
$stop = Clock::now()->plusSeconds(self::TIMEOUT);
while (true) {
if (!$stop->isAfter(Clock::now()) || connection_aborted()) {
$this->layout->renderAjax("[]");
return;
}
session_start();
$events = Event::loadNew();
session_write_close();
if ($events) {
$this->layout->renderAjax(Json::encode(Arrays::map($events, function (Event $event) {
return $event->toJsonArray();
})));
return;
}
Stats::reset();
usleep(100 * 1000);
}
}
示例13: shouldExtractRecursivelyArrayColumn
/**
* @test
*/
public function shouldExtractRecursivelyArrayColumn()
{
//given
$array = array(array('id' => 123, 'name' => 'value1', 'test' => array('number' => 90)), array('id' => 123, 'name' => 'value1', 'test' => array('number' => 100)));
//when
$numbers = Arrays::map($array, Functions::extract()->test->number);
//then
Assert::thatArray($numbers)->hasSize(2)->containsOnly(90, 100);
}
示例14: arrayToString
public static function arrayToString($calls)
{
return Joiner::on(', ')->join(Arrays::map($calls, Functions::toString()));
}
示例15: _printExceptIfExists
private function _printExceptIfExists(RouteRule $rule, $table)
{
$except = $rule->getExcept();
if ($except) {
$table->addRow(array('', '', ' <info>except:</info>', ''));
Arrays::map($except, function ($except) use($table) {
$table->addRow(array('', '', ' ' . $except, ''));
return $except;
});
}
}