Skip to content

Commit aa7ba56

Browse files
committed
2 parents 9d30ead + ee5e0ec commit aa7ba56

File tree

11 files changed

+278
-1
lines changed

11 files changed

+278
-1
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: composer
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
9+
- package-ecosystem: "github-actions"
10+
directory: "/"
11+
schedule:
12+
# Check for updates to GitHub Actions every weekday
13+
interval: "daily"

.github/workflows/php.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Unit-tests
2+
3+
on: [push]
4+
5+
jobs:
6+
test:
7+
name: Test on php ${{ matrix.php}} and ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
timeout-minutes: 10
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
php: [7.3, 7.4, 8.0] #
14+
os: [ubuntu-latest, macOS-latest] # windows-latest,
15+
include:
16+
- os: 'ubuntu-latest'
17+
php: '7.2'
18+
phpunit: '8.5.13'
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
24+
# usage refer https://github.com/shivammathur/setup-php
25+
- name: Setup PHP
26+
timeout-minutes: 5
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php}}
30+
tools: pecl, php-cs-fixer, phpunit:${{ matrix.phpunit }}
31+
extensions: mbstring, dom, fileinfo, mysql, openssl, igbinary, redis # , swoole-4.4.19 #optional, setup extensions
32+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
33+
coverage: none #optional, setup coverage driver: xdebug, none
34+
35+
- name: Display Env
36+
run: env
37+
38+
- name: Install dependencies
39+
run: composer install --no-progress --no-suggest
40+
41+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
42+
# Docs: https://getcomposer.org/doc/articles/scripts.md
43+
44+
- name: Run test suite
45+
run: phpunit

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Tag-release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Test on php ${{ matrix.php}}
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
php: [7.3]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Set ENV for github-release
23+
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
24+
run: |
25+
echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
26+
echo "RELEASE_NAME=$GITHUB_WORKFLOW" >> $GITHUB_ENV
27+
28+
# usage refer https://github.com/shivammathur/setup-php
29+
- name: Setup PHP
30+
timeout-minutes: 5
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php}}
34+
tools: pecl, php-cs-fixer, phpunit
35+
extensions: mbstring, dom, fileinfo, mysql, openssl # , swoole-4.4.19 #optional, setup extensions
36+
ini-values: post_max_size=56M, short_open_tag=On #optional, setup php.ini configuration
37+
coverage: none #optional, setup coverage driver: xdebug, none
38+
39+
- name: Install dependencies # eg: v1.0.3
40+
run: |
41+
tag1=${GITHUB_REF#refs/*/}
42+
echo "release tag: ${tag1}"
43+
composer install --no-progress --no-suggest
44+
45+
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
46+
# Docs: https://getcomposer.org/doc/articles/scripts.md
47+
48+
# - name: Build phar and send to github assets
49+
# run: |
50+
# echo $RELEASE_TAG
51+
# echo $RELEASE_NAME
52+
# php -d phar.readonly=0 bin/kite phar:pack -o kite-${RELEASE_TAG}.phar --no-progress
53+
# php kite-${RELEASE_TAG}.phar -V
54+
55+
# https://github.com/actions/create-release
56+
- uses: meeDamian/github-release@2.0
57+
with:
58+
gzip: false
59+
token: ${{ secrets.GITHUB_TOKEN }}
60+
tag: ${{ env.RELEASE_TAG }}
61+
name: ${{ env.RELEASE_TAG }}
62+
# files: kite-${{ env.RELEASE_TAG }}.phar

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Extlib
2+
3+
[![License](https://img.shields.io/packagist/l/toolkit/extlib.svg?style=flat-square)](LICENSE)
4+
[![Php Version](https://img.shields.io/badge/php-%3E=7.1.0-brightgreen.svg?maxAge=2592000)](https://packagist.org/packages/toolkit/extlib)
5+
[![Latest Stable Version](http://img.shields.io/packagist/v/toolkit/extlib.svg)](https://packagist.org/packages/toolkit/extlib)
6+
[![Actions Status](https://github.com/php-toolkit/extlib/workflows/Unit-tests/badge.svg)](https://github.com/php-toolkit/extlib/actions)
7+
8+
Some useful extends library for php.
9+
10+
## Install
11+
12+
```bash
13+
composer require toolkit/extlib
14+
```
15+
16+
## Usage
17+
18+
19+
## License
20+
21+
MIT

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "toolkit/extlib",
33
"type": "library",
4-
"description": "some useful http client library of the php",
4+
"description": "Some useful extends library for php",
55
"keywords": [
66
"library",
77
"tool",
@@ -20,6 +20,7 @@
2020
"require": {
2121
"php": ">7.1.0",
2222
"toolkit/cli-utils": "^1.0",
23+
"toolkit/fsutil": "^1.0",
2324
"toolkit/stdlib": "^1.0"
2425
},
2526
"autoload": {

src/Contract/IOInterface.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\Contract;
5+
6+
/**
7+
* Interface IOInterface
8+
* @package Toolkit\Extlib\Contract
9+
*/
10+
interface IOInterface extends InputInterface, OutputInterface
11+
{
12+
13+
}

src/Contract/InputInterface.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Toolkit\Extlib\Contract;
4+
5+
/**
6+
* Interface InputInterface
7+
* @package Toolkit\Extlib\Contract
8+
*/
9+
interface InputInterface
10+
{
11+
/**
12+
* @param int $length
13+
*
14+
* @return string
15+
*/
16+
public function read(int $length): string;
17+
18+
/**
19+
* @return string
20+
*/
21+
public function readln(): string;
22+
23+
/**
24+
* @return string
25+
*/
26+
public function readAll(): string;
27+
28+
/**
29+
* Whether the stream is an interactive terminal
30+
*/
31+
public function isInteractive() : bool;
32+
}

src/Contract/OutputInterface.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\Contract;
5+
6+
/**
7+
* Class OutputInterface
8+
*
9+
* @package Toolkit\Extlib\Contract
10+
*/
11+
interface OutputInterface
12+
{
13+
/**
14+
* Write a message to output
15+
*
16+
* @param string $content
17+
*
18+
* @return int
19+
*/
20+
public function write(string $content): int;
21+
22+
/**
23+
* Write a message to output with newline
24+
*
25+
* @param string $content
26+
*
27+
* @return int
28+
*/
29+
public function writeln(string $content): int;
30+
31+
/**
32+
* Whether the stream is an interactive terminal
33+
*/
34+
public function isInteractive() : bool;
35+
}

src/IO/MemoryIO.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\IO;
5+
6+
/**
7+
* Class MemoryIO
8+
* @package Toolkit\Extlib\IO
9+
*/
10+
class MemoryIO
11+
{
12+
13+
}

src/IO/StreamIO.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace Toolkit\Extlib\IO;
5+
6+
/**
7+
* Class StreamIO
8+
* @package Toolkit\Extlib\IO
9+
*/
10+
class StreamIO
11+
{
12+
13+
}

0 commit comments

Comments
 (0)