| @@ -45,18 +45,15 @@ | ||
| 45 | 45 | * Read characters until we reach the given character $char. |
| 46 | 46 | * By default, discard that final matching character and return the rest. |
| 47 | 47 | * |
| 48 | 48 | * @param string $char |
| 49 | - * | |
| 50 | 49 | * @return string |
| 51 | 50 | */ |
| 52 | 51 | public function read_until( $char ) { |
| 53 | 52 | $value = ''; |
| 54 | - | |
| 55 | 53 | while ( $this->pos <= $this->max && ( $one = $this->string[ $this->pos++ ] ) !== $char ) { |
| 56 | 54 | $value .= $one; |
| 57 | 55 | } |
| 58 | - | |
| 59 | 56 | return $value; |
| 60 | 57 | } |
| 61 | 58 | |
| 62 | 59 | /** |
| @@ -64,9 +61,8 @@ | ||
| 64 | 61 | * whichever comes first. |
| 65 | 62 | * By default, remove enclosing double-quotes from the result. |
| 66 | 63 | * |
| 67 | 64 | * @param int $count |
| 68 | - * | |
| 69 | 65 | * @return string |
| 70 | 66 | */ |
| 71 | 67 | public function read( $count ) { |
| 72 | 68 | $value = ''; |
| @@ -84,9 +80,9 @@ | ||
| 84 | 80 | * abc => abc |
| 85 | 81 | * "abc" => abc |
| 86 | 82 | * ""abc"" => "abc" |
| 87 | 83 | */ |
| 88 | - if ( strlen( $value ) < 2 || ! str_starts_with( $value, '"' ) || ! str_ends_with( $value, '"' ) ) { | |
| 84 | + if ( strlen( $value ) < 2 || substr( $value, 0, 1 ) !== '"' || substr( $value, -1, 1 ) !== '"' ) { | |
| 89 | 85 | // Only remove exactly one quote from the start and the end and then only if there is one at each end. |
| 90 | 86 | // Too short, or does not start or end with a quote. |
| 91 | 87 | return $value; |
| 92 | 88 | } |