Skip to content

Commit 101ea5d

Browse files
committed
Initial code
0 parents  commit 101ea5d

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed

Api.php

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
3+
namespace ForkCms\Api;
4+
5+
/**
6+
* @author Tijs Verkoyen <[email protected]>
7+
* @version 1.0.0
8+
* @copyright Copyright (c) 2008, Tijs Verkoyen. All rights reserved.
9+
* @license BSD License
10+
*/
11+
class Api
12+
{
13+
// internal constant to enable/disable debugging
14+
const DEBUG = false;
15+
16+
// current version
17+
const VERSION = '1.0.0';
18+
19+
/**
20+
* The timeout
21+
*
22+
* @var int
23+
*/
24+
private $timeOut = 10;
25+
26+
/**
27+
* The user agent
28+
*
29+
* @var string
30+
*/
31+
private $userAgent;
32+
33+
/**
34+
* Default constructor
35+
*/
36+
public function __construct()
37+
{
38+
}
39+
40+
/**
41+
* Get the timeout that will be used
42+
*
43+
* @return int
44+
*/
45+
public function getTimeOut()
46+
{
47+
return (int) $this->timeOut;
48+
}
49+
50+
/**
51+
* Get the useragent that will be used. Our version will be prepended to
52+
* yours.
53+
* It will look like: "PHP ForkAPI/<version> <your-user-agent>"
54+
*
55+
* @return string
56+
*/
57+
public function getUserAgent()
58+
{
59+
return (string) 'PHP ForkAPI/'. self::VERSION .' '. $this->userAgent;
60+
}
61+
62+
/**
63+
* Set the timeout
64+
* After this time the request will stop. You should handle any errors triggered by this.
65+
*
66+
* @return void
67+
* @param int $seconds The timeout in seconds.
68+
*/
69+
public function setTimeOut($seconds)
70+
{
71+
$this->timeOut = (int) $seconds;
72+
}
73+
74+
/**
75+
* Set the user-agent for you application
76+
* It will be appended to ours, the result will look like: "PHP ForkAPI/<version> <your-user-agent>"
77+
*
78+
* @return void
79+
* @param string $userAgent Your user-agent, it should look like <app-name>/<app-version>.
80+
*/
81+
public function setUserAgent($userAgent)
82+
{
83+
$this->userAgent = (string) $userAgent;
84+
}
85+
}

Exception.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace ForkCms\Api;
3+
4+
/**
5+
* ForkCms Exception class
6+
*
7+
* @author Tijs Verkoyen <tijs@sumocoders>
8+
*/
9+
class Exception extends \Exception
10+
{
11+
}

LICENSE.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright (c) Fork CMS
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# ForkCMS Api class
2+
3+
## About
4+
5+
A (wrapper)class to communicate with the your Fork CMS install.
6+
7+
## Documentation
8+
9+
The class is well documented inline. If you use a decent IDE you'll see that
10+
each method is documented with PHPDoc.

0 commit comments

Comments
 (0)