Skip to content

Commit 74a672d

Browse files
committed
Initial commit
0 parents  commit 74a672d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6386
-0
lines changed

.codacy.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exclude_paths:
2+
- ".phpstorm.meta.php"
3+
- "composer.json"

.editorconfig

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.{neon.dist,yaml,yml}]
18+
indent_size = 2
19+
20+
[Makefile]
21+
indent_style = tab

.gitattributes

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
/.codacy.yml export-ignore
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.phpstorm.meta.php export-ignore
9+
/.travis.yml export-ignore
10+
/codesize.xml export-ignore
11+
/composer.lock export-ignore
12+
/Makefile export-ignore
13+
/phpcs.xml.dist export-ignore
14+
/phpstan.neon.dist export-ignore
15+
/phpunit.xml.dist export-ignore
16+
/tests export-ignore
17+
/tools export-ignore

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.idea/
2+
/tools/*/vendor/
3+
/vendor/
4+
/clover.xml
5+
/phpcs.xml
6+
/phpstan.neon
7+
/phpunit.xml

.phpstorm.meta.php

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of the skriptfabrik PHP OpenSSL package.
4+
*
5+
* @author Daniel Schröder <[email protected]>
6+
*/
7+
8+
namespace PHPSTORM_META {
9+
10+
use PHPUnit\Framework\TestCase;
11+
use Prophecy\Argument;
12+
use Psr\Container\ContainerInterface;
13+
14+
override(
15+
ContainerInterface::get(),
16+
map(
17+
[
18+
'' => '@',
19+
]
20+
)
21+
);
22+
23+
override(
24+
TestCase::getMockForAbstractClass(),
25+
map(
26+
[
27+
'' => '@',
28+
]
29+
)
30+
);
31+
32+
override(
33+
TestCase::getMockForTrait(),
34+
map(
35+
[
36+
'' => '@',
37+
]
38+
)
39+
);
40+
41+
override(
42+
Argument::type(0),
43+
map(
44+
[
45+
'' => '@',
46+
]
47+
)
48+
);
49+
}

.travis.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
language: "bash"
2+
3+
services:
4+
- "docker"
5+
6+
cache:
7+
directories:
8+
- "${HOME}/.composer/cache/files"
9+
10+
env:
11+
global:
12+
- "COMPOSER_HOME=${HOME}/.composer"
13+
14+
install:
15+
- "make install"
16+
17+
script: "make analysis && \
18+
make style-check && \
19+
make tests-with-coverage && \
20+
make coverage-report"

Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export COMPOSER_HOME=${HOME}/.composer/cache/files
2+
3+
.PHONY: install
4+
install:
5+
@echo "Installing dependencies"
6+
@docker-compose run --rm composer composer install
7+
@echo 'Installing development tools'
8+
@docker-compose run --rm composer composer bin all install
9+
10+
.PHONY: analysis
11+
analysis:
12+
@echo "Analysing code"
13+
@docker-compose run --rm php php vendor/bin/phpstan analyse src tests
14+
15+
.PHONY: style-check
16+
style-check:
17+
@echo "Checking code style"
18+
@docker-compose run --rm php php vendor/bin/phpcs -p
19+
20+
.PHONY: style-fix
21+
style-fix:
22+
@echo "Fixing code style"
23+
@docker-compose run --rm php php vendor/bin/phpcbf -p
24+
25+
.PHONY: tests
26+
tests:
27+
@echo "Running tests"
28+
@docker-compose run --rm php php vendor/bin/phpunit
29+
30+
.PHONY: tests-with-coverage
31+
tests-with-coverage:
32+
@echo "Running tests with code coverage"
33+
@docker-compose run --entrypoint /bin/sh --rm php -c " \
34+
echo "zend_extension=xdebug.so" > \$${PHP_INI_DIR}/conf.d/xdebug.ini && \
35+
php vendor/bin/phpunit --coverage-clover clover.xml --coverage-text \
36+
"
37+
38+
.PHONY: coverage-report
39+
coverage-report:
40+
@echo "Reporting code coverage"
41+
@docker-compose run --rm php php vendor/bin/codacycoverage clover clover.xml

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# skriptfabrik PHP OpenSSL package
2+
3+
## Usage
4+
5+
Run `$ vendor/bin/openssl help [<command_name>]` to display the usage details for a specific command.
6+
7+
### Generate a private key
8+
9+
The default private key file with the name `private.pem` will be generated to the current working directory. You can
10+
specify the `--type` and `--bits` as an option. If you want to keep an existing private key, append the `--no-override`
11+
option to the command.
12+
13+
```bash
14+
$ vendor/bin/openssl openssl:generate-private-key [<output>]
15+
```
16+
17+
### Export the public key with OpenSSL
18+
19+
The default public key file with the name `public.pem` will be exported to the current working directory. The private
20+
key is expected to be named `private.pem`. It should also be stored in the working directory per default. If you want to
21+
keep an existing public key, append the `--no-override` option to the command.
22+
23+
```bash
24+
$ vendor/bin/openssl openssl:export-public-key [<input>] [<output>]
25+
```
26+
27+
## Development
28+
29+
### Requirements
30+
31+
The development of this project is powered by [Docker](https://www.docker.com/), Docker Compose and
32+
[GNU Make](http://www.gnu.org/software/make). Please have a look at the [Makefile](Makefile) for exact commands.
33+
34+
### Install dependencies and development tools
35+
36+
This will install all Composer dependencies and development tools.
37+
38+
```bash
39+
$ make install
40+
```
41+
42+
### Analyse code
43+
44+
The code analysis is being performed with PHPStan.
45+
46+
```bash
47+
$ make analysis
48+
```
49+
50+
### Check code style
51+
52+
The code style is being checked with PHP_CodeSniffer.
53+
54+
```bash
55+
$ make style-check
56+
```
57+
58+
### Fix code style
59+
60+
Some minor code style issues can be fixed with PHP_CodeSniffer.
61+
62+
```bash
63+
$ make style-fix
64+
```
65+
66+
### Run Tests
67+
68+
```bash
69+
$ make tests
70+
```
71+
72+
### Run Tests With Coverage
73+
74+
```bash
75+
$ make tests-with-coverage
76+
```

bin/openssl

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env php
2+
<?php declare(strict_types=1);
3+
/**
4+
* This file is part of the skriptfabrik PHP OpenSSL package.
5+
*
6+
* @author Daniel Schröder <[email protected]>
7+
*/
8+
9+
return require __DIR__ . '/openssl.php';

bin/openssl.php

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of the skriptfabrik PHP OpenSSL package.
4+
*
5+
* @author Daniel Schröder <[email protected]>
6+
*/
7+
8+
foreach ([
9+
__DIR__ . '/../../../autoload.php',
10+
__DIR__ . '/../../vendor/autoload.php',
11+
__DIR__ . '/../vendor/autoload.php'
12+
] as $file) {
13+
if (file_exists($file)) {
14+
define('COMPOSER_AUTOLOAD_FILE', $file);
15+
16+
break;
17+
}
18+
}
19+
20+
if (!defined('COMPOSER_AUTOLOAD_FILE')) {
21+
fwrite(
22+
STDERR,
23+
'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL .
24+
' composer install' . PHP_EOL . PHP_EOL .
25+
'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL
26+
);
27+
28+
die(1);
29+
}
30+
31+
/** @noinspection PhpIncludeInspection */
32+
require COMPOSER_AUTOLOAD_FILE;
33+
34+
$application = new Skriptfabrik\Openssl\Console\Application();
35+
$application->addCommands([
36+
new Skriptfabrik\Openssl\Console\Command\GeneratePrivateKeyCommand(),
37+
new Skriptfabrik\Openssl\Console\Command\ExportPublicKeyCommand(),
38+
]);
39+
40+
return $application->run();

codesize.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="pcsg-generated-ruleset"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
<description>Created with the PHP Coding Standard Generator.
8+
http://edorian.github.com/php-coding-standard-generator/
9+
</description>
10+
11+
<include-pattern>./src</include-pattern>
12+
<include-pattern>./tests</include-pattern>
13+
14+
<rule ref="rulesets/controversial.xml"/>
15+
16+
<rule ref="rulesets/design.xml/ExitExpression"/>
17+
<rule ref="rulesets/design.xml/EvalExpression"/>
18+
<rule ref="rulesets/design.xml/GotoStatement"/>
19+
<rule ref="rulesets/design.xml/NumberOfChildren"/>
20+
21+
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass"/>
22+
<rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
23+
<rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
24+
25+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
26+
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
27+
</ruleset>

0 commit comments

Comments
 (0)