for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare( strict_types = 1 );
namespace Maps\WikitextParsers;
use Maps\LegacyModel\WmsOverlay;
use ValueParsers\ParseException;
use ValueParsers\ValueParser;
/**
* ValueParser that parses the string representation of a WMS layer
*
* @since 3.0
* @licence GNU GPL v2+
* @author Jeroen De Dauw < [email protected] >
*/
class WmsOverlayParser implements ValueParser {
* Parses the provided string and returns the result.
* @param string $value
* @return WmsOverlay
* @throws ParseException
public function parse( $value ) {
if ( !is_string( $value ) ) {
throw new ParseException( 'Not a string' );
}
$separator = " ";
$metaData = explode( $separator, $value );
if ( count( $metaData ) >= 2 ) {
$wmsOverlay = new WmsOverlay( $metaData[0], $metaData[1] );
if ( count( $metaData ) == 3 ) {
$wmsOverlay->setWmsStyleName( $metaData[2] );
return $wmsOverlay;
throw new ParseException( 'Need at least two parameters, url to WMS server and map layer name' );