<?php
class Service
{
public function __construct( $url )
{
$this->url = $url;
}
protected function correctPaths()
{
foreach( $this->images as $id => $image )
{
if( substr( $image, 0, 1 ) == '/' )
{
$this->images[$id] = preg_replace( '#(http://[^/]+).*#sim', '\\1', $this->url ) . $image;
}
if( substr( $image, 0, 7 ) != 'http://' && substr( $image, 0, 1 ) != '/' )
{
$this->images[$id] = substr( $this->url, 0, strrpos( $this->url, '/' ) + 1 ) . $image;
}
}
}
}
?>