Skip to content

Commit

Permalink
Merge pull request #1 from vldmr-k/phpstan-fixing
Browse files Browse the repository at this point in the history
Phpstan fixing
  • Loading branch information
vldmr-k authored Oct 15, 2022
2 parents 8050a5d + 2ca7006 commit 5bc5216
Show file tree
Hide file tree
Showing 58 changed files with 1,067 additions and 343 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ composer.phar
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock

spec/_coverage
phpspec.yaml
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG VERSION

FROM php:${VERSION}-cli-alpine

WORKDIR /app

RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
&& pecl install xdebug \
&& apk del pcre-dev ${PHPIZE_DEPS}

RUN docker-php-ext-install -j$(nproc) bcmath

RUN curl -sS https://getcomposer.org/installer | \
php -- --2 --install-dir=/usr/local/bin --filename=composer
40 changes: 40 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
default_php_version:=7.4
default_server_port:=8080
php_version:=$(PHP_VERSION)
server_port:=$(PORT)

ifndef PHP_VERSION
php_version:=$(default_php_version)
endif

ifndef PORT
server_port:=$(default_server_port)
endif

base_dir:=$(shell basename $(CURDIR))
docker:=docker run --rm -v $(CURDIR):/app -w /app $(base_dir):$(php_version)

build:
docker build --build-arg VERSION=$(php_version) --tag $(base_dir):$(php_version) .

exec:
docker run --rm -ti -v $(CURDIR):/app:rw -w /app $(base_dir):$(php_version) sh

serve:
docker run -p$(server_port):8080 --rm -v $(CURDIR):/app -w /app $(base_dir):$(php_version) php -S 0.0.0.0:8080

install:
$(docker) composer install

install-no-dev:
$(docker) composer install --no-dev

static-analyze:
$(docker) composer static

unit:
$(docker) -dzend_extension=xdebug.so -dxdebug.mode=coverage vendor/bin/phpspec run

all: build install static-analyze unit

.PHONY: build
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
### Examples
Before run example, please set global variable `MONO_XTOKEN`


###### Retrieve public key
```php
$token = '...';
$config = new \VldmrK\MonoAcquiring\Config($token);

$api = new \VldmrK\MonoAcquiring\Api($config);

$response = $api->call(new \VldmrK\MonoAcquiring\Query\PubkeyQuery());

print_r($response->toArray()); // ['key' => '....']
```

###### Merchant Details
```php
$token = '...';
$config = new \VldmrK\MonoAcquiring\Config($token);

$api = new \VldmrK\MonoAcquiring\Api($config);

$response = $api->call(new \VldmrK\MonoAcquiring\Query\DetailsQuery());

print_r($response); // [ 'merchantId' => 'test_A4EaPDryzz', 'merchantName' => 'Test Caption']
```

More example you can find here [example/](example/)

### Run Test
```shell script
make build
make test
```

### Coverage

After run tests, you can check coverage of code
```shell script
make serve
```

After that, coverage report will be available by address http://0.0.0.0:8080/spec/_coverage/index.html
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"description": "Monobank Acquiring library",
"type": "library",
"require": {
"starkbank/ecdsa": "^2.0",
"guzzlehttp/guzzle": "^7.5"
"guzzlehttp/guzzle": "^7.5",
"starkbank/ecdsa": "0.0.5"
},
"require-dev": {
"php": "^7.4|^8.0",
"phpspec/phpspec": "^7.2",
"friends-of-phpspec/phpspec-code-coverage": "^6.1"
"friends-of-phpspec/phpspec-code-coverage": "^6.1",
"squizlabs/php_codesniffer": "3.*",
"phpstan/phpstan": "~1.0.0"
},
"license": "MIT",
"autoload": {
Expand All @@ -23,6 +26,8 @@
}
],
"scripts": {
"test": "./vendor/bin/phpspec run"
"static": [
"vendor/bin/phpcs --ignore-annotations --standard=PSR12 src && vendor/bin/phpstan analyse "
]
}
}
Loading

0 comments on commit 5bc5216

Please sign in to comment.