예제 #1
0
/**
 * f\rename_keys($coll, $keysMap)
 *
 * Returns a new coll with the keys from keysMap renamed.
 *
 * f\rename_keys(array('a' => 1, 'b' => 2), array('a' => 'c', 'b' => 'd'))
 * => array('c' => 1, 'd' => 2)
 */
function rename_keys($coll, $keysMap)
{
    if (f\not($keysMap)) {
        return $coll;
    }
    $from = f\first(f\keys($keysMap));
    $to = f\first($keysMap);
    return f\rename_keys(f\rename_key($coll, $from, $to), f\dissoc($keysMap, $from));
}
 private function getInputDataFromRequest(Request $request)
 {
     return f\dissoc($request->request->all(), 'grant_type');
 }
예제 #3
0
 /**
  * Responsible for removing the id.
  */
 public function remove(Client $client)
 {
     $this->allToFile(f\dissoc($this->allFromFile(), f\get($client, 'id')));
 }
예제 #4
0
 /**
  * @dataProvider dissocProvider
  */
 public function testAssoc($coll)
 {
     $this->assertSame(array(1 => 'o', 3 => 'tr'), f\dissoc($coll, 2));
     $this->assertSame(array(1 => 'o', 2 => 't'), f\dissoc($coll, 3));
 }
예제 #5
0
/**
 * f\rename_key($coll, $from, $to)
 *
 * Returns a new coll with a key renamed from from to to.
 *
 * f\rename_key(array('a' => 1), 'a', 'b')
 * => array('b' => 1)
 */
function rename_key($coll, $from, $to)
{
    return f\assoc(f\dissoc($coll, $from), $to, f\get($coll, $from));
}