/** * Tests Arr::to_assoc() * * @test */ public function test_to_assoc_with_odd_number_of_elements() { $arr = array('foo', 'bar', 'baz'); $expected = null; $this->assertEquals($expected, Arr::to_assoc($arr)); }
/** * Converts the current URI segments to an associative array. If * the URI has an odd number of segments, an empty value will be added. * * @param int segment number to start from. default value is the first segment * @return array the assoc array */ public static function to_assoc($start = 1) { $segments = array_slice(static::segments(), $start - 1); count($segments) % 2 and $segments[] = null; return \Arr::to_assoc($segments); }
/** * Converts the current URI segments to an associative array. If * the URI has an odd number of segments, null will be returned. * * @return array|null the array or null */ public static function to_assoc() { return \Arr::to_assoc(static::segments()); }
/** * Tests Arr::to_assoc() * * @test * @expectedException BadMethodCallException */ public function test_to_assoc_with_odd_number_of_elements() { $arr = array('foo', 'bar', 'baz'); Arr::to_assoc($arr); }