php-upnp/src/SSDP/Service.php

51 lines
1.1 KiB
PHP

<?php
namespace NoccyLabs\UPnP\SSDP;
/*
<serviceType>urn:schemas-upnp-org:service:Layer3Forwarding:1</serviceType>
<serviceId>urn:upnp-org:serviceId:L3Forwarding1</serviceId>
<SCPDURL>/L3F.xml</SCPDURL>
<controlURL>/ctl/L3F</controlURL>
<eventSubURL>/evt/L3F</eventSubURL>
*/
use SimpleXMLElement;
class Service
{
protected $serviceType;
protected $serviceId;
protected $scpdUrl;
protected $controlUrl;
protected $eventSubUrl;
public function __construct(SimpleXMLElement $spec)
{
$this->serviceType = (string)$spec->serviceType;
$this->serviceId = (string)$spec->serviceId;
$this->scpdUrl = (string)$spec->SCPDURL;
$this->controlUrl = (string)$spec->controlURL;
$this->eventSubUrl = (string)$spec->eventSubURL;
}
public function __toString()
{
return sprintf("Service: %s [%s]\nControl URL: %s\nEventSub URL: %s\nSCPD URL: %s\n",
$this->serviceId,
$this->serviceType,
$this->controlUrl,
$this->eventSubUrl,
$this->scpdUrl
);
}
}