Skip to content

Commit

Permalink
Merge 71a08c7 into 1359935
Browse files Browse the repository at this point in the history
  • Loading branch information
zquintana committed Nov 10, 2020
2 parents 1359935 + 71a08c7 commit 0dfcd33
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 228 deletions.
4 changes: 4 additions & 0 deletions .coveralls.yml
@@ -0,0 +1,4 @@
service_name: travis-pro
repo_token: aHR2Vq500iS9DEQu5bwcAR2rotYnEqMq2
coverage_clover: tmp/clover.xml
json_path: tmp/coveralls.json
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
vendor/
composer.lock
.phpunit.result.cache
16 changes: 16 additions & 0 deletions .travis.yml
@@ -0,0 +1,16 @@
language: php
php:
- "7.2"

cache:
directories:
- vendor

install:
- composer install

script:
- composer run-script test-all

after_success:
- travis_retry php vendor/bin/php-coveralls -v
19 changes: 17 additions & 2 deletions composer.json
Expand Up @@ -10,12 +10,27 @@
}
],
"require": {
"php": "^7.0",
"php": "^7.1",
"phpseclib/phpseclib": "^2.0"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.4",
"zingle-com/php-coding-standard": "^0.0.1",
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
"Zingle\\": "src/Zingle"
"Zingle\\Infrastructure\\": "src/",
"Zingle\\Infrastructure\\Test\\": "tests/"
}
},
"scripts": {
"test": "./vendor/bin/phpunit",
"test-no-coverage": "@test --no-coverage",
"check-standards": "./vendor/bin/phpcs -p",
"test-all": [
"@check-standards",
"@test"
]
}
}
110 changes: 0 additions & 110 deletions composer.lock

This file was deleted.

6 changes: 6 additions & 0 deletions phpcs.xml.dist
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="vendor/zingle-com/php-coding-standard" />

<file>./src</file>
</ruleset>
28 changes: 28 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<php>
<ini name="error_reporting" value="-1" />
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="tmp/clover.xml" />
</logging>
</phpunit>
63 changes: 63 additions & 0 deletions src/Agent.php
@@ -0,0 +1,63 @@
<?php

namespace Zingle\Infrastructure;

use phpseclib\Crypt\RSA;

/**
* Zingle infrastructure user agent.
*/
class Agent
{
/**
* @var string
*/
private $user;

/**
* @var RSA
*/
private $key;


/**
* Configure agent credentials.
*
* @param string $user
* @param string $keyData
*/
public function __construct(string $user, string $keyData)
{
$this->user = $user;
$this->setKey($keyData);
}

/**
* Return the agent user name.
*
* @return string
*/
public function getUser(): string
{
return $this->user;
}

/**
* Return the agent RSA key.
*
* @return RSA
*/
public function getKey(): RSA
{
return $this->key;
}

/**
* @param string $keyData
*/
private function setKey(string $keyData): void
{
$this->key = new RSA();
$this->key->loadKey($keyData);
}
}

0 comments on commit 0dfcd33

Please sign in to comment.