Code Monkey home page Code Monkey logo

polr-client's Introduction

Polr API Client

Latest Stable Version Total Downloads Latest Unstable Version Maintainability Semantic Versioning License

Introduction

REST API client written in PHP for cydrobolt/polr

Provides simple interface for interaction with Polr instances

Usage

Very minimal example, using default configuration

<?php

namespace NorthernLights\Client\Polr\Example;

use NorthernLights\Client\Polr\ApiClient;
use NorthernLights\Client\Polr\Config\Config;
use NorthernLights\Client\Polr\Response\ShortenResponseInterface;


/**
 * Initialize API client and pass $config to it (DI)
 * @var ApiClient $api
 */
$api = new ApiClient();

/**
 * Shorten the long URL.
 * @var ShortenResponseInterface $response
 */
$response = $api->shorten('https://www.polrproject.org');

// Check if API request was successful. Remains true as long as HTTP status code equals 200 OK
if (!$response->wasSuccessful()) {
    echo 'There was an error querying the api' . PHP_EOL;
    exit(1);
}

echo 'Short URL is ' . $response->getShortUrl() . PHP_EOL;

For more detailed examples and configuration, please take a look in examples. All use scenarios are covered.

Installation

The recommended way to install is via Composer:

composer require northern-lights/polr-client

Alternatively, you can download latest stable version from releases.

Please note that this library doesn't ship with autoloader, but relies on Composer internal autoloader.

Industry standards and best practices

Library strives to comply with latest standards and best practices in the industry therefore we included

PSR-2 coding standard Compliance check & fix

We want the code to be as good as it is possible

$ composer check-style
$ composer fix-style

Note: Second command will actually modify files

Code syntax check (lint)

Very basic check which saves us the trouble

$ composer php-lint

Static Code Analysis

So we catch bugs early.

$ composer phpsam

Unit testing

So we make sure that all moving parts are running smoothly

$ composer test

TODO

Disclaimer

This project or it's authors are not affiliated with the Polr Project or any third party.

License

The MIT License (MIT). Please see License File for more information.

polr-client's People

Contributors

xzero707 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

hemverket

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.