Skip to content
This repository was archived by the owner on Jul 2, 2021. It is now read-only.

Commit 3c9ddcb

Browse files
committed
Inital Release
0 parents  commit 3c9ddcb

19 files changed

+513
-0
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/var/cache/*
2+
!tests/var/cache/.gitkeep
3+
tests/var/logs/*
4+
!tests/var/logs/.gitkeep
5+
vendor/
6+
7+
.php_cs.cache
8+
composer.lock
9+
php-cs-fixer

.phpcs.php

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in(__DIR__)
5+
->exclude('tests/var/')
6+
->exclude('vendor')
7+
->files()
8+
->name('*.php')
9+
;
10+
11+
$config = PhpCsFixer\Config::create()
12+
->setRiskyAllowed(true)
13+
->setFinder($finder)
14+
->setRules([
15+
'@PSR2' => true,
16+
'@Symfony' => true,
17+
'@Symfony:risky' => true,
18+
'align_multiline_comment' => ['comment_type' => 'all_multiline'],
19+
'array_indentation' => true,
20+
'array_syntax' => true,
21+
'blank_line_before_return' => true,
22+
'class_keyword_remove' => false,
23+
'combine_consecutive_issets' => true,
24+
'combine_consecutive_unsets' => true,
25+
'comment_to_phpdoc' => true,
26+
'compact_nullable_typehint' => true,
27+
'date_time_immutable' => true,
28+
'escape_implicit_backslashes' => [
29+
'double_quoted' => false,
30+
'heredoc_syntax' => true,
31+
'single_quoted' => true,
32+
],
33+
'explicit_indirect_variable' => true,
34+
'explicit_string_variable' => true,
35+
'final_internal_class' => true,
36+
'fully_qualified_strict_types' => true,
37+
'heredoc_to_nowdoc' => true,
38+
'linebreak_after_opening_tag' => true,
39+
'list_syntax' => true,
40+
'mb_str_functions' => true,
41+
'method_chaining_indentation' => true,
42+
'multiline_comment_opening_closing' => true,
43+
'multiline_whitespace_before_semicolons' => true,
44+
'native_function_invocation' => true,
45+
'no_alternative_syntax' => true,
46+
'no_blank_lines_before_namespace' => false,
47+
'no_null_property_initialization' => true,
48+
'no_php4_constructor' => true,
49+
'no_short_echo_tag' => true,
50+
'no_superfluous_elseif' => true,
51+
'no_unreachable_default_argument_value' => true,
52+
'no_useless_else' => true,
53+
'no_useless_return' => true,
54+
'not_operator_with_space' => true,
55+
'not_operator_with_successor_space' => true,
56+
'ordered_class_elements' => true,
57+
'ordered_imports' => true,
58+
'php_unit_dedicate_assert' => [
59+
'target' => 'newest',
60+
],
61+
'php_unit_expectation' => true,
62+
'php_unit_mock' => true,
63+
'php_unit_namespaced' => true,
64+
'php_unit_no_expectation_annotation' => true,
65+
'php_unit_ordered_covers' => true,
66+
'php_unit_strict' => true,
67+
'php_unit_test_annotation' => true,
68+
'php_unit_test_class_requires_covers' => true,
69+
'phpdoc_add_missing_param_annotation' => [
70+
'only_untyped' => false,
71+
],
72+
'phpdoc_order' => true,
73+
'phpdoc_types_order' => true,
74+
'psr0' => true,
75+
'simplified_null_return' => true,
76+
'strict_comparison' => true,
77+
'strict_param' => true,
78+
'string_line_ending' => true,
79+
])
80+
;
81+
82+
return $config;

.travis.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
language: php
2+
sudo: false
3+
4+
env:
5+
global:
6+
- secure: p1AHe7WuwIKb/kzGisKsAFCBeiBQFF71p01TWfhvhawo1OF+ytfuAWQ9OUVFbBlANdiX2VbF8LkK1Pnkj0NLAHSry1kdyhLyEw54gTaOB66O1hf/1GBP8p9MljtGtDcBvreTtA3huEjW9eAyBeFD0IcN8NxNx6nKct7RsOHy+isiDbhezqwrYzoKVax5TaqTGb5zy1XeJRUbR4k7ZthKTcygvapmGEPLg3/Qidp6qPO2MhGwTWHu7oBUdE0cUbzrNVr1PCYZ6MYqQzLLUJDNCgsss/ap+2FTxz8ePLSXP8ce+zao0Mr3W+DCI+X1tHkgCSk9b1usj8RemUzu6dWSZqbAo2XyVWhlUSqgKDS43Dou17A35q9Dw6DkfbVhZQv9nAjhq492HcdhYBITg822L/sSo1oOems2awZlV9vRyr10ugMN6gI+KuyZkRyH36aO76IwjDx6+LL8rjrr1IXYV9EFCWWGS79Wa4QQaug5KvBc7vIaMPUGvUGhkZ2gYQuBN7cREGpgdie97dBlWA/UdCo9ecpWEzO5S2/UBu7fmRncAvFLFnW/UR2ZhYKXtY52BwBsmGQ/4LaJY7LaUGlptrf3Z6N6WC2Pev3V2be0KvcoCsnq2S/ZKgk0oN+SofTAKkm6EA8Ozl8MITlXTQKzkHcUH/VKH/uITIF5jsgsc88=
7+
- secure: ha1UWXrQE555rvQ+UQCYf4lDdoAFui8NPNvEilr55Q4E3mWH58wHi6BI7XrAZR3I61V+FLUXRmGtucyOhHIJOeTryZT21PL8hm/MHt54k0A0VZ7oweO2cNQe+gFdaN1ibt5Dxyf2VSpiabnCSyjrbBgQYlVUCJKKUxiC2+V/PUmY5RU74d3yKWBzxnELYe6T3x0bHpYVKiTOuMMIg2Wg0iVvyTPJM4MlKHiYXLIsgk0FcL1wnBJyFWg2RJKAUsAwZFgc6G1TNTckAY60NBoX/5jNM3sqTtPws5s/nikqOM4QARz+L8TzQodUD0zJe3QfTVuC31Q3xhQq1vOg+RxENUscI+nApSPEbUWaGRQ/mPU+ToWgUzyRR80upnsgYOncPGeXMsq90fP73DDYZYOXE8P4tDz5JPsCF8kajyed2GeyzYBUD+XfZ6eYjAagfrLCP71GdQGkdcGzbz2OSBv84jdfaGT6xpRJx78OvuCm0pawU+ZPyK55Q1UWOW6aQijNVySHO15ND5R9VLmpYpgBbWZRBGAfnBV1U3BA7XtvR/shIzDeBJHIrygvQPIw3SV8stICIDsQANHHQxlggTbiJSfeDwMHToN/dFhuwN2Pp4xS9zok666Oniga+KuhROo4VyGFy6YV2fx1GQIAWxLW/MfC5KlPcenVi0hj8h1CXW4=
8+
9+
matrix:
10+
fast_finish: true
11+
include:
12+
- php: 5.6
13+
env: SYMFONY_VERSION=2.7.*
14+
- php: 5.6
15+
env: SYMFONY_VERSION=2.8.*
16+
- php: 5.6
17+
env: SYMFONY_VERSION=3.4.*
18+
- php: 7.0
19+
env: SYMFONY_VERSION=2.7.*
20+
- php: 7.0
21+
env: SYMFONY_VERSION=2.8.*
22+
- php: 7.0
23+
env: SYMFONY_VERSION=3.4.*
24+
- php: 7.1
25+
env: SYMFONY_VERSION=2.7.*
26+
- php: 7.1
27+
env: SYMFONY_VERSION=2.8.*
28+
- php: 7.1
29+
env: SYMFONY_VERSION=3.4.*
30+
- php: 7.1
31+
env: SYMFONY_VERSION=4.0.*
32+
- php: 7.2
33+
env: SYMFONY_VERSION=2.7.*
34+
- php: 7.2
35+
env: SYMFONY_VERSION=2.8.*
36+
- php: 7.2
37+
env: SYMFONY_VERSION=3.4.*
38+
- php: 7.2
39+
env: SYMFONY_VERSION=4.0.*
40+
41+
before_install:
42+
- phpenv config-rm xdebug.ini || echo "xdebug not available";
43+
- echo "memory_limit=1G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini;
44+
45+
install:
46+
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update "symfony/framework-bundle:${SYMFONY_VERSION}"; fi;
47+
- composer install --no-interaction
48+
49+
before_script:
50+
- wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer && chmod +x php-cs-fixer
51+
52+
script:
53+
- "./vendor/bin/phpunit -c phpunit.dist.xml"
54+
- "./php-cs-fixer fix --config .phpcs.php --diff --dry-run --no-interaction -v"

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changelog
2+
## v0.1.0
3+
* Initial Release

LICENSE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2018 Sebastian Sellmeier
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# INWX Service Provider for Symfony
2+
3+
[![Build Status](https://travis-ci.org/SebTM/inwx-api-bundle.svg?branch=master)](https://travis-ci.org/SebTM/inwx-api-bundle)
4+
[![Total Downloads](https://img.shields.io/packagist/dt/SebTM/inwx-api-bundle.svg)](https://packagist.org/packages/SebTM/inwx-api-bundle)
5+
[![GitHub license](https://img.shields.io/github/license/SebTM/inwx-api-bundle.svg)](https://github.com/SebTM/inwx-api-bundle/blob/master/LICENSE.md)
6+
7+
A Symfony bundle for including the [INWX PHP-Client](https://github.com/inwx/php-client).
8+
9+
## Installation
10+
11+
The INWX bundle can be installed via [Composer](http://getcomposer.org) by
12+
requiring the `sebtm/inwx-api-bundle` package in your project's `composer.json`:
13+
14+
```json
15+
{
16+
"require": {
17+
"sebtm/inwx-api-bundle": "~0.1"
18+
}
19+
}
20+
```
21+
22+
and adding an instance of `SebTM\INWX\InwxApiBundle` to your application's kernel:
23+
24+
```php
25+
class AppKernel extends Kernel
26+
{
27+
public function registerBundles()
28+
{
29+
return [
30+
...
31+
new \SebTM\INWX\InwxApiBundle(),
32+
];
33+
}
34+
...
35+
}
36+
```
37+
(This is NOT needed for Symfony-Flex while using recipes!)
38+
39+
## Configuration
40+
### Sample YML Configuration
41+
42+
The sample configuration which can be placed in `app/config/config.yml` file.
43+
44+
```yaml
45+
inwx_api:
46+
environment: "production"
47+
username: "username"
48+
password: "password"
49+
language: "en"
50+
debug: false
51+
```
52+
53+
Supported environments: "production", "test"
54+
Supported languages: see documentation of INWX PHP-Client
55+
56+
## Usage
57+
58+
This bundle exposes an instance of the `SebTM\INWX\Domrobot` object:
59+
60+
```
61+
Service | Instance Of
62+
--- | ---
63+
inwx_api | SebTM\INWX\Domrobot
64+
```
65+
66+
## Links
67+
* [INWX PHP-Client on Github](https://github.com/inwx/php-client)
68+
* [INWX PHP-Client Documentation](https://www.inwx.de/en/help/apidoc)
69+
* [License](https://opensource.org/licenses/MIT)
70+
* [Symfony website](http://symfony.com/)

composer.json

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "sebtm/inwx-api-bundle",
3+
"description": "A Symfony bundle for using \"inwx/php-client\".",
4+
"keywords": [ "inwx", "php", "client", "api", "symfony"],
5+
"type": "symfony-bundle",
6+
"minimum-stability": "stable",
7+
"license": "MIT",
8+
"authors": [
9+
{
10+
"name": "Sebastian Sellmeier",
11+
"email": "mail@sebastian-sellmeier.de"
12+
}
13+
],
14+
"require": {
15+
"php": ">=5.6",
16+
"inwx/domrobot": "^2.4"
17+
},
18+
"require-dev": {
19+
"symfony/framework-bundle": "^2.7|^2.8|^3.4|^4.0",
20+
"symfony/yaml": "^2.7|^2.8|^3.4|^4.0",
21+
"phpunit/phpunit": "^5.7|^6.5|^7.0"
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"SebTM\\INWX\\": "src/"
26+
}
27+
},
28+
"autoload-dev": {
29+
"psr-4": {
30+
"SebTM\\INWX\\Tests\\": "tests/"
31+
}
32+
},
33+
"config": {
34+
"sort-packages": true
35+
},
36+
"prefer-stable": true
37+
}

phpunit.dist.xml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.0/phpunit.xsd"
4+
backupGlobals="false"
5+
colors="true"
6+
>
7+
<php>
8+
<ini name="error_reporting" value="-1" />
9+
<ini name="display_errors" value="On" />
10+
<ini name="display_startup_errors" value="On" />
11+
<ini name="date.timezone" value="Europe/Berlin" />
12+
<env name="APP_ENV" value="test" />
13+
<env name="APP_DEBUG" value="1" />
14+
</php>
15+
16+
<testsuites>
17+
<testsuite name="INWX-Api-Bundle tests">
18+
<directory>./tests/</directory>
19+
</testsuite>
20+
</testsuites>
21+
</phpunit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
namespace SebTM\INWX\DependencyInjection;
4+
5+
use SebTM\INWX\Exception\InvalidConfigurationException;
6+
use Symfony\Component\Config\FileLocator;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
use Symfony\Component\DependencyInjection\Extension\Extension;
9+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
10+
11+
class InwxApiExtension extends Extension
12+
{
13+
/**
14+
* @param array $configs
15+
* @param ContainerBuilder $container
16+
*
17+
* @throws \Exception Error occurred while parsing "services.yml"
18+
* @throws InvalidConfigurationException Missing environment-variable to construct a client-instance
19+
*/
20+
public function load(array $configs, ContainerBuilder $container)
21+
{
22+
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config/'));
23+
$loader->load('services.yml');
24+
25+
$config = array(
26+
'environment' => \getenv('INWX_API_ENVIRONMENT'),
27+
'username' => \getenv('INWX_API_USERNAME'),
28+
'password' => \getenv('INWX_API_PASSWORD'),
29+
'language' => \getenv('INWX_API_LANGUAGE'),
30+
'debug' => \filter_var(\getenv('INWX_API_DEBUG'), FILTER_VALIDATE_BOOLEAN),
31+
);
32+
33+
$validate = \array_search(false, $config, true);
34+
if (false !== $validate && 'debug' !== $validate) {
35+
throw new InvalidConfigurationException();
36+
}
37+
38+
$definition = $container->getDefinition('inwx_api');
39+
$definition->replaceArgument(0, $config['environment']);
40+
$definition->replaceArgument(1, $config['username']);
41+
$definition->replaceArgument(2, $config['password']);
42+
$definition->replaceArgument(3, $config['language']);
43+
$definition->replaceArgument(4, $config['debug']);
44+
}
45+
}

src/Domrobot.php

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace SebTM\INWX;
4+
5+
use INWX\Domrobot as BaseDomrobot;
6+
7+
class Domrobot extends BaseDomrobot
8+
{
9+
/**
10+
* @var string
11+
*/
12+
protected $environment;
13+
14+
/**
15+
* @param string $environment
16+
* @param string $username
17+
* @param string $password
18+
* @param string $language
19+
* @param bool $debug
20+
*
21+
* @throws \Exception
22+
*/
23+
public function __construct($environment, $username, $password, $language = 'en', $debug = false)
24+
{
25+
$this->environment = $environment;
26+
parent::__construct($this->getAddress($environment));
27+
28+
$this->setLanguage($language);
29+
$this->setDebug($debug);
30+
$this->login($username, $password);
31+
}
32+
33+
/**
34+
* @return string
35+
*/
36+
public function getEnvironment()
37+
{
38+
return $this->environment;
39+
}
40+
41+
/**
42+
* @param string $environment
43+
*
44+
* @throws \Exception Unsupported environment
45+
*
46+
* @return string
47+
*/
48+
protected function getAddress($environment)
49+
{
50+
switch ($environment) {
51+
case 'production':
52+
return ' https://api.domrobot.com/xmlrpc/';
53+
54+
case 'test':
55+
return 'https://api.ote.domrobot.com/xmlrpc/';
56+
57+
default:
58+
throw new \Exception('Unsupported environment!');
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)