Skip to content

Instantly share code, notes, and snippets.

@spudro228
Created February 5, 2019 14:51
Show Gist options
  • Save spudro228/ce43f6425c99e07635f2dff2d9236e69 to your computer and use it in GitHub Desktop.
Save spudro228/ce43f6425c99e07635f2dff2d9236e69 to your computer and use it in GitHub Desktop.
<?php
$code = <<<'CODE'
protected $baseUrl = '/api/countries';
$client->request('GET', $this->baseUrl . "kek");
$client->request('GET', $this->baseUrl.'kek');
CODE;
$re = '/((protected|public)\s+\$baseUrl\s+=\s+\'(?<url>[\/\w+]+)\')/m';
preg_match_all($re, $code, $matches, PREG_SET_ORDER);
// \vardump()
$url = $matches[0]['url'];
echo preg_replace('/(\$this->baseUrl)/m', $url , $code);
// echo $code;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment