Skip to content

Commit

Permalink
use exceptins for error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Sep 2, 2016
1 parent 346260a commit 2a2a522
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 6 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
}
],
"require": {
"php": "^5.4||^7.0",
"php": "^5.4|^7.0",
"goetas-webservices/xsd-reader": "^0.2",
"symfony/event-dispatcher" : "^2.2"
},
"require-dev" : {
"phpunit/phpunit" : "^4.8|^5.0",
"sami/sami" : "~2.0",
"jmikola/wildcard-event-dispatcher": "~1.0"
},
"autoload": {
Expand Down
6 changes: 5 additions & 1 deletion src/DefinitionsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use GoetasWebservices\XML\WSDLReader\Wsdl\PortType\Param;
use GoetasWebservices\XML\WSDLReader\Wsdl\Service;
use GoetasWebservices\XML\WSDLReader\Wsdl\Service\Port;
use GoetasWebservices\XML\XSDReader\Exception\IOException;
use GoetasWebservices\XML\XSDReader\Schema\Schema;
use GoetasWebservices\XML\XSDReader\SchemaReader;
use GoetasWebservices\XML\XSDReader\Utils\UrlUtils;
Expand Down Expand Up @@ -509,8 +510,11 @@ public function readFile($file)
private function getDOM($file)
{
$xml = new DOMDocument('1.0', 'UTF-8');
if (!$xml->load($file)) {
if (!$xml->load($file, LIBXML_NONET)) {
print_r(libxml_get_errors());
die();
throw new IOException("Can't load the file $file");

}
return $xml;
}
Expand Down
7 changes: 7 additions & 0 deletions src/Exception/OperationNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Exception;

class OperationNotFoundException extends \Exception
{

}
7 changes: 7 additions & 0 deletions src/Exception/PartNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Exception;

class PartNotFoundException extends \Exception
{

}
7 changes: 7 additions & 0 deletions src/Exception/PortNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Exception;

class PortNotFoundException extends \Exception
{

}
7 changes: 7 additions & 0 deletions src/Exception/ServiceNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Exception;

class ServiceNotFoundException extends \Exception
{

}
2 changes: 2 additions & 0 deletions src/Wsdl/Definitions.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Wsdl;

use GoetasWebservices\XML\WSDLReader\Exception\ServiceNotFoundException;
use GoetasWebservices\XML\XSDReader\Schema\Schema;

/**
Expand Down Expand Up @@ -225,6 +226,7 @@ public function getService($name)
if (isset($this->service[$name])) {
return $this->service[$name];
}
throw new ServiceNotFoundException("The service named $name can not be found inside $this->name");
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Wsdl/Message.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Wsdl;
use GoetasWebservices\XML\WSDLReader\Exception\PartNotFoundException;

/**
* XSD Type: tMessage
Expand Down Expand Up @@ -69,7 +70,10 @@ public function getParts()
*/
public function getPart($name)
{
return $this->part[$name];
if (isset($this->part[$name])) {
return $this->part[$name];
}
throw new PartNotFoundException("The part named $name can not be found inside $this->name message");
}

}
6 changes: 5 additions & 1 deletion src/Wsdl/PortType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Wsdl;
use GoetasWebservices\XML\WSDLReader\Exception\OperationNotFoundException;

/**
* XSD Type: tPortType
Expand Down Expand Up @@ -56,7 +57,10 @@ public function addOperation(\GoetasWebservices\XML\WSDLReader\Wsdl\PortType\Ope
*/
public function getOperation($name)
{
return $this->operation[$name];
if (isset($this->operation[$name])) {
return $this->operation[$name];
}
throw new OperationNotFoundException("The operation named $name can not be found inside $this->name port type");
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/Wsdl/Service.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace GoetasWebservices\XML\WSDLReader\Wsdl;
use GoetasWebservices\XML\WSDLReader\Exception\PortNotFoundException;

/**
* XSD Type: tService
Expand Down Expand Up @@ -54,7 +55,10 @@ public function addPort(\GoetasWebservices\XML\WSDLReader\Wsdl\Service\Port $por

public function getPort($name)
{
return $this->port[$name];
if (isset($this->port[$name])){
return $this->port[$name];
}
throw new PortNotFoundException("The port named $name can not be found inside $this->name");
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Wsdl/Service/Port.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public function __construct(Service $service, $name)
$this->service = $service;
}

public function getService()
{
return $this->service;
}

/**
* @return string
*/
Expand Down

0 comments on commit 2a2a522

Please sign in to comment.