Skip to content

Commit

Permalink
Properly handle optional info-token-type on 1.8 login responses. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
troydavisson committed Sep 30, 2017
1 parent 7dc7352 commit 34d5ecd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

_Release TBD_

- Fix RETS 1.8 login response parsing for optional info-token-type

## 2.4

_Released June 28, 2017_
Expand Down
29 changes: 23 additions & 6 deletions src/Parsers/Login/OneEight.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace PHRETS\Parsers\Login;

use Illuminate\Support\Str;

class OneEight extends OneX
{
public function readLine($line)
Expand All @@ -13,14 +15,29 @@ public function readLine($line)

if ($name == 'Info') {
if ($value) {
list($name, $type, $value) = explode(';', $value);
if ($type == 'Int') {
$value = (int) $value;
} elseif ($type == 'Boolean') {
$value = (bool) $value;
// break it up on the 2 required parts
list($info_token_name, $info_token_value) = explode(';', $value, 2);

$info_token_type = null;

// see if the optional 3rd part was given
if (Str::contains($info_token_value, ';')) {
// they included the optional type
list($info_token_type, $info_token_value) = explode(';', $info_token_value);

if ($info_token_type == 'Int') {
$info_token_value = (int) $info_token_value;
} elseif ($info_token_type == 'Boolean') {
$info_token_value = (bool) $info_token_value;
} else {
$info_token_value = trim($info_token_value);
}
} else {
$value = trim($value);
$info_token_value = trim($info_token_value);
}

$name = $info_token_name;
$value = $info_token_value;
}
}

Expand Down

0 comments on commit 34d5ecd

Please sign in to comment.