├── .github └── workflows │ ├── php-cs-fixer.yml │ ├── psalm.yml │ └── run-tests.yml ├── .php_cs.dist ├── .phpunit.result.cache ├── LICENSE ├── README.md ├── composer.json ├── psalm.xml.dist └── src └── Spinner.php /.github/workflows/php-cs-fixer.yml: -------------------------------------------------------------------------------- 1 | name: Check & fix styling 2 | 3 | on: [push] 4 | 5 | jobs: 6 | php-cs-fixer: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | with: 13 | ref: ${{ github.head_ref }} 14 | 15 | - name: Run PHP CS Fixer 16 | uses: docker://oskarstark/php-cs-fixer-ga 17 | with: 18 | args: --config=.php_cs.dist --allow-risky=yes 19 | 20 | - name: Commit changes 21 | uses: stefanzweifel/git-auto-commit-action@v4 22 | with: 23 | commit_message: Fix styling 24 | -------------------------------------------------------------------------------- /.github/workflows/psalm.yml: -------------------------------------------------------------------------------- 1 | name: Psalm 2 | 3 | on: 4 | push: 5 | paths: 6 | - '**.php' 7 | - 'psalm.xml.dist' 8 | 9 | jobs: 10 | psalm: 11 | name: psalm 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | 16 | - name: Setup PHP 17 | uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: '7.4' 20 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 21 | coverage: none 22 | 23 | - name: Cache composer dependencies 24 | uses: actions/cache@v2 25 | with: 26 | path: vendor 27 | key: composer-${{ hashFiles('composer.lock') }} 28 | 29 | - name: Run composer install 30 | run: composer install -n --prefer-dist 31 | 32 | - name: Run psalm 33 | run: ./vendor/bin/psalm --output-format=github 34 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: true 10 | matrix: 11 | os: [ubuntu-latest, windows-latest] 12 | php: [8.0, 7.4] 13 | stability: [prefer-lowest, prefer-stable] 14 | 15 | name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} 16 | 17 | steps: 18 | - name: Checkout code 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup PHP 22 | uses: shivammathur/setup-php@v2 23 | with: 24 | php-version: ${{ matrix.php }} 25 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 26 | coverage: none 27 | 28 | - name: Setup problem matchers 29 | run: | 30 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 31 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 32 | 33 | - name: Install dependencies 34 | run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction 35 | 36 | - name: Execute tests 37 | run: vendor/bin/phpunit 38 | -------------------------------------------------------------------------------- /.php_cs.dist: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->ignoreDotFiles(true) 10 | ->ignoreVCS(true); 11 | 12 | return PhpCsFixer\Config::create() 13 | ->setRules([ 14 | '@PSR12' => true, 15 | '@PSR2' => true, 16 | 'array_syntax' => ['syntax' => 'short'], 17 | 'ordered_imports' => ['sortAlgorithm' => 'alpha'], 18 | 'no_unused_imports' => true, 19 | 'not_operator_with_successor_space' => true, 20 | 'trailing_comma_in_multiline_array' => true, 21 | 'phpdoc_scalar' => true, 22 | 'unary_operator_spaces' => true, 23 | 'binary_operator_spaces' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 26 | ], 27 | 'phpdoc_single_line_var_spacing' => true, 28 | 'phpdoc_var_without_name' => true, 29 | 'class_attributes_separation' => [ 30 | 'elements' => [ 31 | 'method', 32 | ], 33 | ], 34 | 'method_argument_space' => [ 35 | 'on_multiline' => 'ensure_fully_multiline', 36 | 'keep_multiple_spaces_after_comma' => true, 37 | ], 38 | 'single_trait_insert_per_statement' => true, 39 | ]) 40 | ->setFinder($finder); 41 | -------------------------------------------------------------------------------- /.phpunit.result.cache: -------------------------------------------------------------------------------- 1 | C:37:"PHPUnit\Runner\DefaultTestResultCache":109:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:1:{s:49:"PiedWeb\TextSpinner\Test\SpinnerTest::testSpinner";d:0.008;}}} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | =========== 3 | 4 | Copyright (c) Robin Delattre https://piedweb.com 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Open Source Package 3 |

4 | 5 | # Text Spinner 6 | 7 | [![Latest Version](https://img.shields.io/github/tag/piedweb/textspinner.svg?style=flat&label=release)](https://github.com/piedweb/textspinner/tags) 8 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE) 9 | [![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/piedweb/textspinner/Tests?label=tests)](https://github.com/piedweb/textspinner/actions) 10 | [![Quality Score](https://img.shields.io/scrutinizer/g/piedweb/textspinner.svg?style=flat)](https://scrutinizer-ci.com/g/piedweb/textspinner) 11 | [![Code Coverage](https://codecov.io/gh/piedweb/textspinner/branch/main/graph/badge.svg)](https://codecov.io/gh/piedweb/textspinner/branch/main) 12 | [![Type Coverage](https://shepherd.dev/github/piedweb/textspinner/coverage.svg)](https://shepherd.dev/github/piedweb/textspinner) 13 | [![Total Downloads](https://img.shields.io/packagist/dt/piedweb/text-spinner.svg?style=flat)](https://packagist.org/packages/piedweb/text-spinner) 14 | 15 | Generate content from a spinned text (content spinning via spinning tool ak rephraser). 16 | 17 | ## Install 18 | 19 | Via [Packagist](https://img.shields.io/packagist/dt/piedweb/text-spinner.svg?style=flat) 20 | 21 | ``` bash 22 | $ composer require piedweb/text-spinner 23 | ``` 24 | 25 | ## Usage 26 | 27 | ``` php 28 | use PiedWeb\TextSpinner\Spinner; 29 | 30 | $text = 'my {{first|second|third}|{first|second|third}|{first|second|third}} text.'; 31 | $spinText = Spinner::spin($text); 32 | ``` 33 | 34 | ## Testing 35 | 36 | ``` bash 37 | $ composer test 38 | ``` 39 | 40 | ## Contributing 41 | 42 | Please see [contributing](https://dev.piedweb.com/contributing) 43 | 44 | ## Credits 45 | 46 | - [Pied Web](https://piedweb.com) 47 | - [All Contributors](https://github.com/PiedWeb/:package_skake/graphs/contributors) 48 | 49 | ## License 50 | 51 | The MIT License (MIT). Please see [License File](LICENSE) for more information. 52 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "piedweb/text-spinner", 3 | "type": "library", 4 | "description": "Generate content from a spinned text (content spinning via spinning tool ak rephraser)", 5 | "keywords": [ 6 | "Pied Web", 7 | "TextSpinner" 8 | ], 9 | "homepage": "https://dev.piedweb.com", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Robin D. (ak Pied Web)", 14 | "email": "contact@robin-d.fr", 15 | "homepage": "https://piedweb.com" 16 | } 17 | ], 18 | "require": { 19 | "php": "^7.1|^8.0" 20 | }, 21 | "require-dev": { 22 | "phpunit/phpunit": ">=7.0", 23 | "squizlabs/php_codesniffer": "^3.0", 24 | "vimeo/psalm": "^4.4" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "PiedWeb\\TextSpinner\\": "src" 29 | } 30 | }, 31 | "autoload-dev": { 32 | "psr-4": { 33 | "PiedWeb\\TextSpinner\\": "tests" 34 | } 35 | }, 36 | "scripts": { 37 | "test": "phpunit", 38 | "check-style": "phpcs src tests", 39 | "fix-style": "phpcbf src tests" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /psalm.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Spinner.php: -------------------------------------------------------------------------------- 1 |