Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 #7

Merged
merged 3 commits into from
Dec 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ php:
matrix:
allow_failures:
- php: "hhvm"
- php: "nightly"

9 changes: 9 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "flammy/fsapi",
"description": "Frontier Silicon API for PHP",
"require": {
"php": "^5.3.3 || ^7.0",
"php-xml": "^5.3.3 || ^7.0",
"php-curl": "^5.3.3 || ^7.0"
}
}
93 changes: 0 additions & 93 deletions examples/fsapi.php

This file was deleted.

63 changes: 0 additions & 63 deletions examples/radio.php

This file was deleted.

37 changes: 0 additions & 37 deletions examples/ssdp.php

This file was deleted.

3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<phpunit colors="true" bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="fsapi Test Suite">
<directory>tests/</directory>
<directory suffix="Test.php">tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src</directory>
Expand Down
8 changes: 8 additions & 0 deletions src/Exceptions/NodeExeption.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Exception which is thrown by the Node Class
*
*/
class NodeException extends Exception
{
}
8 changes: 8 additions & 0 deletions src/Exceptions/ParserException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Exception which is thrown by the Parser Class
*
*/
class ParserException extends Exception
{
}
8 changes: 8 additions & 0 deletions src/Exceptions/RadioException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Exception which is thrown by the Parser Class
*
*/
class RadioException extends Exception
{
}
8 changes: 8 additions & 0 deletions src/Exceptions/RequestException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Exception which is thrown by the Request Class
*
*/
class RequestException extends Exception
{
}
8 changes: 8 additions & 0 deletions src/Exceptions/ValidatorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Exception which is thrown by the Validator Class
*
*/
class ValidatorException extends Exception
{
}
59 changes: 59 additions & 0 deletions src/FSAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
class FSAPI implements Requests
{
protected $call_method_whitelist = array('CREATE_SESSION','DELETE_SESSION','GET_NOTIFIES');
protected $Request = null;

/**
* create a new FSAPI-Object
*
* @var object Request $Request The Request Object which does the actual Request
*
*
*/
public function __construct(Request $Request)
{
$this->Request = $Request;
}


/**
* Do the request-call via the Request Object
*
* @var string $method The method (GET,SET,...)
*
* @var string $node The name of the Node (netRemote.sys.info.version)
*
* @var array $attributes Additional attributes for the request (pin, session,...)
*
* @var string $delimiter Delimiter is necessary for some functions, it is added as a virtual folder to the url
*
* @throws RequestException if request fails
*
* @return string - plain request data on success false on error
*
*/
public function doRequest($method, $node = null, $attributes = array(), $delimiter = "")
{
if ($node !== null) {
// whitelisted via node
if ($node->checkCallMethods($method) == false) {
return false;
}
} else {
// whitelisted via global whitelist
if (!in_array($method, $call_method_whitelist)) {
return false;
}
}

if (isset($attributes['value'])) {
// input-validation if there is a new value
if (!$node->validateInput($attributes['value'])) {
return false;
}
}

return $this->Request->doRequest($method, $node, $attributes, $delimiter);
}
}
Loading