/** @test */
 public function it_creates_a_numeric_array_when_the_value_delimiter_is_not_found()
 {
     $testString = 'param1>value1,param2?value2,param3=value3';
     $expected = array('param1>value1', 'param2?value2', 'param3' => 'value3');
     $result = StringHelper::toAssociativeArray($testString, ',', '=');
     $this->assertEquals($expected, $result);
 }
Exemple #2
0
 public function renderWithTemplate($template)
 {
     $search = array(':url', ':label', ':attributes');
     $attributeString = StringHelper::arrayToHtmlAttributeString($this->attributes);
     $replace = array($this->url, $this->label, $attributeString);
     return str_replace($search, $replace, $template);
 }
 protected function parseRulesFromString($ruleString)
 {
     $parsedRules = array();
     $ruleStrings = explode('|', $ruleString);
     foreach ($ruleStrings as $singleRule) {
         $rule = StringHelper::splice(':', $singleRule);
         $ruleParams = StringHelper::toAssociativeArray($singleRule);
         if ($rule == null && $singleRule[0] == '/') {
             $rule = 'url';
         }
         $parsedRules[$rule] = $ruleParams;
     }
     return $parsedRules;
 }