PDF rausgenommen
This commit is contained in:
12
msd2/myoos/vendor/fig/link-util/.editorconfig
vendored
Normal file
12
msd2/myoos/vendor/fig/link-util/.editorconfig
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
21
msd2/myoos/vendor/fig/link-util/LICENSE.md
vendored
Normal file
21
msd2/myoos/vendor/fig/link-util/LICENSE.md
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 :author_name <:author_email>
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
7
msd2/myoos/vendor/fig/link-util/README.md
vendored
Normal file
7
msd2/myoos/vendor/fig/link-util/README.md
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
PSR Http Link Utilities
|
||||
=======================
|
||||
|
||||
This repository includes common utilities to assist with implementing [PSR-13](http://www.php-fig.org/psr/psr-13/).
|
||||
|
||||
Note that it is not intended as a complete PSR-13 implementation, only a partial implementation
|
||||
to make writing other implementations easier.
|
35
msd2/myoos/vendor/fig/link-util/composer.json
vendored
Normal file
35
msd2/myoos/vendor/fig/link-util/composer.json
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "fig/link-util",
|
||||
"description": "Common utility implementations for HTTP links",
|
||||
"keywords": ["psr", "psr-13", "http", "http-link", "link", "rest"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.5.0",
|
||||
"psr/link": "~1.0@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.1",
|
||||
"squizlabs/php_codesniffer": "^2.3.1"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Fig\\Link\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Fig\\Link\\Test\\": "test/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
21
msd2/myoos/vendor/fig/link-util/phpcs.xml
vendored
Normal file
21
msd2/myoos/vendor/fig/link-util/phpcs.xml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="PSR-2 coding standard">
|
||||
<description>PSR-2 coding standards</description>
|
||||
|
||||
<!-- display progress -->
|
||||
<arg value="p"/>
|
||||
<arg name="colors"/>
|
||||
|
||||
<!-- inherit rules from: -->
|
||||
<rule ref="PSR2"/>
|
||||
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
|
||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
|
||||
<properties>
|
||||
<property name="ignoreBlankLines" value="false"/>
|
||||
</properties>
|
||||
</rule>
|
||||
|
||||
<!-- Paths to check -->
|
||||
<file>src</file>
|
||||
<file>test</file>
|
||||
</ruleset>
|
40
msd2/myoos/vendor/fig/link-util/src/EvolvableLinkProviderTrait.php
vendored
Normal file
40
msd2/myoos/vendor/fig/link-util/src/EvolvableLinkProviderTrait.php
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\LinkInterface;
|
||||
use Psr\Link\EvolvableLinkProviderInterface;
|
||||
|
||||
/**
|
||||
* Class EvolvableLinkProviderTrait
|
||||
*
|
||||
* @implements EvolvableLinkProviderInterface
|
||||
*/
|
||||
trait EvolvableLinkProviderTrait
|
||||
{
|
||||
use LinkProviderTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withLink(LinkInterface $link)
|
||||
{
|
||||
$that = clone($this);
|
||||
$splosh = spl_object_hash($link);
|
||||
if (!array_key_exists($splosh, $that->links)) {
|
||||
$that->links[$splosh] = $link;
|
||||
}
|
||||
return $that;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withoutLink(LinkInterface $link)
|
||||
{
|
||||
$that = clone($this);
|
||||
$splosh = spl_object_hash($link);
|
||||
unset($that->links[$splosh]);
|
||||
return $that;
|
||||
}
|
||||
}
|
84
msd2/myoos/vendor/fig/link-util/src/EvolvableLinkTrait.php
vendored
Normal file
84
msd2/myoos/vendor/fig/link-util/src/EvolvableLinkTrait.php
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\EvolvableLinkInterface;
|
||||
|
||||
/**
|
||||
* Class EvolvableLinkTrait
|
||||
*
|
||||
* @implements EvolvableLinkInterface
|
||||
*/
|
||||
trait EvolvableLinkTrait
|
||||
{
|
||||
use LinkTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return EvolvableLinkInterface
|
||||
*/
|
||||
public function withHref($href)
|
||||
{
|
||||
/** @var EvolvableLinkInterface $that */
|
||||
$that = clone($this);
|
||||
$that->href = $href;
|
||||
|
||||
$that->templated = ($this->hrefIsTemplated($href));
|
||||
|
||||
return $that;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return EvolvableLinkInterface
|
||||
*/
|
||||
public function withRel($rel)
|
||||
{
|
||||
/** @var EvolvableLinkInterface $that */
|
||||
$that = clone($this);
|
||||
$that->rel[$rel] = true;
|
||||
return $that;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return EvolvableLinkInterface
|
||||
*/
|
||||
public function withoutRel($rel)
|
||||
{
|
||||
/** @var EvolvableLinkInterface $that */
|
||||
$that = clone($this);
|
||||
unset($that->rel[$rel]);
|
||||
return $that;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return EvolvableLinkInterface
|
||||
*/
|
||||
public function withAttribute($attribute, $value)
|
||||
{
|
||||
/** @var EvolvableLinkInterface $that */
|
||||
$that = clone($this);
|
||||
$that->attributes[$attribute] = $value;
|
||||
return $that;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return EvolvableLinkInterface
|
||||
*/
|
||||
public function withoutAttribute($attribute)
|
||||
{
|
||||
/** @var EvolvableLinkInterface $that */
|
||||
$that = clone($this);
|
||||
unset($that->attributes[$attribute]);
|
||||
return $that;
|
||||
}
|
||||
}
|
29
msd2/myoos/vendor/fig/link-util/src/GenericLinkProvider.php
vendored
Normal file
29
msd2/myoos/vendor/fig/link-util/src/GenericLinkProvider.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\EvolvableLinkProviderInterface;
|
||||
use Psr\Link\LinkInterface;
|
||||
|
||||
class GenericLinkProvider implements EvolvableLinkProviderInterface
|
||||
{
|
||||
use EvolvableLinkProviderTrait;
|
||||
|
||||
/**
|
||||
* Constructs a new link provider.
|
||||
*
|
||||
* @param LinkInterface[] $links
|
||||
* Optionally, specify an initial set of links for this provider.
|
||||
* Note that the keys of the array will be ignored.
|
||||
*/
|
||||
public function __construct(array $links = [])
|
||||
{
|
||||
// This block will throw a type error if any item isn't a LinkInterface, by design.
|
||||
array_filter($links, function (LinkInterface $item) {
|
||||
return true;
|
||||
});
|
||||
|
||||
$hashes = array_map('spl_object_hash', $links);
|
||||
$this->links = array_combine($hashes, $links);
|
||||
}
|
||||
}
|
27
msd2/myoos/vendor/fig/link-util/src/Link.php
vendored
Normal file
27
msd2/myoos/vendor/fig/link-util/src/Link.php
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\EvolvableLinkInterface;
|
||||
|
||||
class Link implements EvolvableLinkInterface
|
||||
{
|
||||
use EvolvableLinkTrait;
|
||||
|
||||
/**
|
||||
* Link constructor.
|
||||
*
|
||||
* @param string $rel
|
||||
* A single relationship to include on this link.
|
||||
* @param string $href
|
||||
* An href for this link.
|
||||
*/
|
||||
public function __construct($rel = '', $href = '')
|
||||
{
|
||||
if ($rel) {
|
||||
$this->rel[$rel] = true;
|
||||
}
|
||||
$this->href = $href;
|
||||
}
|
||||
}
|
44
msd2/myoos/vendor/fig/link-util/src/LinkProviderTrait.php
vendored
Normal file
44
msd2/myoos/vendor/fig/link-util/src/LinkProviderTrait.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\LinkProviderInterface;
|
||||
use Psr\Link\LinkInterface;
|
||||
|
||||
/**
|
||||
* Class LinkProviderTrait
|
||||
*
|
||||
* @implements LinkProviderInterface
|
||||
*/
|
||||
trait LinkProviderTrait
|
||||
{
|
||||
/**
|
||||
* An array of the links in this provider.
|
||||
*
|
||||
* The keys of the array MUST be the spl_object_hash() of the object being stored.
|
||||
* That helps to ensure uniqueness.
|
||||
*
|
||||
* @var LinkInterface[]
|
||||
*/
|
||||
private $links = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLinksByRel($rel)
|
||||
{
|
||||
$filter = function (LinkInterface $link) use ($rel) {
|
||||
return in_array($rel, $link->getRels());
|
||||
};
|
||||
return array_filter($this->links, $filter);
|
||||
}
|
||||
}
|
73
msd2/myoos/vendor/fig/link-util/src/LinkTrait.php
vendored
Normal file
73
msd2/myoos/vendor/fig/link-util/src/LinkTrait.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
use Psr\Link\LinkInterface;
|
||||
|
||||
/**
|
||||
* Class LinkTrait
|
||||
*
|
||||
* @inherits LinkInterface
|
||||
*/
|
||||
trait LinkTrait
|
||||
{
|
||||
use TemplatedHrefTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $href = '';
|
||||
|
||||
/**
|
||||
* The set of rels on this link.
|
||||
*
|
||||
* Note: Because rels are an exclusive set, we use the keys of the array
|
||||
* to store the rels that have been added, not the values. The values
|
||||
* are simply boolean true. A rel is present if the key is set, false
|
||||
* otherwise.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $rel = [];
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $attributes = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHref()
|
||||
{
|
||||
return $this->href;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isTemplated()
|
||||
{
|
||||
return $this->hrefIsTemplated($this->href);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRels()
|
||||
{
|
||||
return array_keys($this->rel);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
}
|
23
msd2/myoos/vendor/fig/link-util/src/TemplatedHrefTrait.php
vendored
Normal file
23
msd2/myoos/vendor/fig/link-util/src/TemplatedHrefTrait.php
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link;
|
||||
|
||||
trait TemplatedHrefTrait
|
||||
{
|
||||
/**
|
||||
* Determines if an href is a templated link or not.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc6570
|
||||
*
|
||||
* @param string $href
|
||||
* The href value to check.
|
||||
*
|
||||
* @return bool
|
||||
* True if the specified href is a templated path, False otherwise.
|
||||
*/
|
||||
private function hrefIsTemplated($href)
|
||||
{
|
||||
return strpos($href, '{') !== false ||strpos($href, '}') !== false;
|
||||
}
|
||||
}
|
77
msd2/myoos/vendor/fig/link-util/test/GenericLinkProviderTest.php
vendored
Normal file
77
msd2/myoos/vendor/fig/link-util/test/GenericLinkProviderTest.php
vendored
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link\Tests;
|
||||
|
||||
use Fig\Link\GenericLinkProvider;
|
||||
use Fig\Link\Link;
|
||||
|
||||
class GenericLinkProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function test_can_add_links_by_method()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$provider = (new GenericLinkProvider())
|
||||
->withLink($link);
|
||||
|
||||
$this->assertContains($link, $provider->getLinks());
|
||||
}
|
||||
|
||||
|
||||
public function test_can_add_links_by_constructor()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$provider = (new GenericLinkProvider())
|
||||
->withLink($link);
|
||||
|
||||
$this->assertContains($link, $provider->getLinks());
|
||||
}
|
||||
|
||||
public function test_can_get_links_by_rel()
|
||||
{
|
||||
$link1 = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
$link2 = (new Link())
|
||||
->withHref('http://www.php-fig.org/')
|
||||
->withRel('home')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$provider = (new GenericLinkProvider())
|
||||
->withLink($link1)
|
||||
->withLink($link2);
|
||||
|
||||
$links = $provider->getLinksByRel('home');
|
||||
$this->assertContains($link2, $links);
|
||||
$this->assertFalse(in_array($link1, $links));
|
||||
}
|
||||
|
||||
public function test_can_remove_links()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$provider = (new GenericLinkProvider())
|
||||
->withLink($link)
|
||||
->withoutLink($link);
|
||||
|
||||
$this->assertFalse(in_array($link, $provider->getLinks()));
|
||||
}
|
||||
}
|
59
msd2/myoos/vendor/fig/link-util/test/LinkTest.php
vendored
Normal file
59
msd2/myoos/vendor/fig/link-util/test/LinkTest.php
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Fig\Link\Tests;
|
||||
|
||||
use Fig\Link\Link;
|
||||
|
||||
class LinkTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function test_can_set_and_retrieve_values()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$this->assertEquals('http://www.google.com', $link->getHref());
|
||||
$this->assertContains('next', $link->getRels());
|
||||
$this->assertArrayHasKey('me', $link->getAttributes());
|
||||
$this->assertEquals('you', $link->getAttributes()['me']);
|
||||
}
|
||||
|
||||
public function test_can_remove_values()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withAttribute('me', 'you')
|
||||
;
|
||||
|
||||
$link = $link->withoutAttribute('me')
|
||||
->withoutRel('next');
|
||||
|
||||
$this->assertEquals('http://www.google.com', $link->getHref());
|
||||
$this->assertFalse(in_array('next', $link->getRels()));
|
||||
$this->assertFalse(array_key_exists('me', $link->getAttributes()));
|
||||
}
|
||||
|
||||
public function test_multiple_rels()
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref('http://www.google.com')
|
||||
->withRel('next')
|
||||
->withRel('reference');
|
||||
|
||||
$this->assertCount(2, $link->getRels());
|
||||
$this->assertContains('next', $link->getRels());
|
||||
$this->assertContains('reference', $link->getRels());
|
||||
}
|
||||
|
||||
public function test_constructor()
|
||||
{
|
||||
$link = new Link('next', 'http://www.google.com');
|
||||
|
||||
$this->assertEquals('http://www.google.com', $link->getHref());
|
||||
$this->assertContains('next', $link->getRels());
|
||||
}
|
||||
}
|
56
msd2/myoos/vendor/fig/link-util/test/TemplatedHrefTraitTest.php
vendored
Normal file
56
msd2/myoos/vendor/fig/link-util/test/TemplatedHrefTraitTest.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Fig\Link\Tests;
|
||||
|
||||
|
||||
use Fig\Link\Link;
|
||||
|
||||
class TemplatedHrefTraitTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider templatedHrefProvider
|
||||
*
|
||||
* @param string $href
|
||||
* The href to check.
|
||||
*/
|
||||
public function test_templated($href)
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref($href);
|
||||
|
||||
$this->assertTrue($link->isTemplated());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @dataProvider notTemplatedHrefProvider
|
||||
*
|
||||
* @param string $href
|
||||
* The href to check.
|
||||
*/
|
||||
public function test_not_templated($href)
|
||||
{
|
||||
$link = (new Link())
|
||||
->withHref($href);
|
||||
|
||||
$this->assertFalse($link->isTemplated());
|
||||
}
|
||||
|
||||
public function templatedHrefProvider()
|
||||
{
|
||||
return [
|
||||
['http://www.google.com/{param}/foo'],
|
||||
['http://www.google.com/foo?q={param}'],
|
||||
];
|
||||
}
|
||||
|
||||
public function notTemplatedHrefProvider()
|
||||
{
|
||||
return [
|
||||
['http://www.google.com/foo'],
|
||||
['/foo/bar/baz'],
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user