diff --git a/lib/Transport/Entity/Schedule/Connection.php b/lib/Transport/Entity/Schedule/Connection.php index dfc9d4d..b303f69 100644 --- a/lib/Transport/Entity/Schedule/Connection.php +++ b/lib/Transport/Entity/Schedule/Connection.php @@ -155,7 +155,14 @@ public static function createFromJson($json, Connection $obj = null) } $obj->duration = gmdate('0z\dH:i:s', $json->duration); - $obj->transfers = count($json->legs) - 1; + + $numberOfVehicles = 0; + foreach ($json->legs as $leg) { + if (isset($leg->type) && $leg->type != 'walk') { + $numberOfVehicles++; + } + } + $obj->transfers = $numberOfVehicles - 1; if (isset($json->legs)) { foreach ($json->legs as $leg) { diff --git a/test/fixtures/connections/response_2016-12-23.json b/test/fixtures/connections/response_2016-12-23.json index fc7ab2f..34a698b 100644 --- a/test/fixtures/connections/response_2016-12-23.json +++ b/test/fixtures/connections/response_2016-12-23.json @@ -78,7 +78,7 @@ } }, "duration": "00d00:15:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IR" @@ -334,7 +334,7 @@ } }, "duration": "00d00:28:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "S12" @@ -894,7 +894,7 @@ } }, "duration": "00d00:15:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IR" @@ -1150,7 +1150,7 @@ } }, "duration": "00d00:20:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IR" diff --git a/test/fixtures/connections/response_2017-06-20.json b/test/fixtures/connections/response_2017-06-20.json index af08e6d..485637a 100644 --- a/test/fixtures/connections/response_2017-06-20.json +++ b/test/fixtures/connections/response_2017-06-20.json @@ -78,7 +78,7 @@ } }, "duration": "00d00:30:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IC" @@ -334,7 +334,7 @@ } }, "duration": "00d00:30:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IC" @@ -590,7 +590,7 @@ } }, "duration": "00d00:30:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IC" @@ -846,7 +846,7 @@ } }, "duration": "00d00:30:00", - "transfers": 1, + "transfers": 0, "service": null, "products": [ "IC"