Add using example and implementation example

parent 620d44a3
......@@ -13,5 +13,12 @@
"require": {
"fguillot/json-rpc": "@stable"
},
"autoload": {
"psr-4": {
"Etersoft\\Typos\\": "src/",
"My\\": "example/"
}
}
}
<?php
namespace My;
use Etersoft\Typos\TyposArticle;
use Etersoft\Typos\TyposClientInterface;
/**
* Client interface example implementation
*/
class MyClientInterface extends TyposClientInterface {
/**
* Should return an article text for a provided article link.
*
* @param string $link A link to a article. User should define an article id.
*
* @return \Etersoft\Typos\TyposArticle
*/
protected function getArticleFromLink(string $link)
{
return new TyposArticle(0, "");
}
/**
* Should persist a provided article in database.
*
* @param \Etersoft\Typos\TyposArticle $article Article
* @return void
*/
protected function saveArticle(TyposArticle $article)
{
}
}
\ No newline at end of file
<?php
/**
* Example script of using etersoft/typos_client package
*/
require __DIR__ . '/../vendor/autoload.php';
use My\MyClientInterface;
$interface = new MyClientInterface();
$client = new \Etersoft\Typos\TyposClient($interface);
echo $client->run();
\ No newline at end of file
......@@ -8,7 +8,7 @@
namespace Etersoft\Typos;
// Enable autoloading
require __DIR__ . '../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
use JsonRPC\Server;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment