diff --git a/.travis.yml b/.travis.yml index 13f201c6f..0e8536ba5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,6 +21,7 @@ install: - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/inky-extra && travis_retry composer install) - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/intl-extra && travis_retry composer install) - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/markdown-extra && travis_retry composer install) + - ([[ $TRAVIS_PHP_VERSION < 7.2 ]] || cd extra/string-extra && travis_retry composer install) script: - ./vendor/bin/simple-phpunit @@ -29,6 +30,7 @@ script: - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/inky-extra && ./vendor/bin/simple-phpunit) - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/intl-extra && ./vendor/bin/simple-phpunit) - ([[ $TRAVIS_PHP_VERSION = 7.0 ]] || cd extra/markdown-extra && ./vendor/bin/simple-phpunit) + - ([[ $TRAVIS_PHP_VERSION < 7.2 ]] || cd extra/string-extra && ./vendor/bin/simple-phpunit) jobs: fast_finish: true diff --git a/extra/string-extra/.gitignore b/extra/string-extra/.gitignore new file mode 100644 index 000000000..76367ee5b --- /dev/null +++ b/extra/string-extra/.gitignore @@ -0,0 +1,4 @@ +vendor/ +composer.lock +phpunit.xml +.phpunit.result.cache diff --git a/extra/string-extra/LICENSE b/extra/string-extra/LICENSE new file mode 100644 index 000000000..1a1869751 --- /dev/null +++ b/extra/string-extra/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/extra/string-extra/README.md b/extra/string-extra/README.md new file mode 100644 index 000000000..cef5799d5 --- /dev/null +++ b/extra/string-extra/README.md @@ -0,0 +1,10 @@ +String Extension +================ + +This package is a Twig extension that provides integration with the Symfony String component. + +It provides a single [`u`][1] filter that wraps a text in a `UnicodeString` object to give access to [methods of the class](https://symfony.com/doc/current/components/string.html). + +`{{ 'Symfony String + Twig = <3'|u.wordwrap(5) }}` + +[1]: https://twig.symfony.com/u diff --git a/extra/string-extra/composer.json b/extra/string-extra/composer.json new file mode 100644 index 000000000..8a9e27f60 --- /dev/null +++ b/extra/string-extra/composer.json @@ -0,0 +1,39 @@ +{ + "name": "twig/string-extra", + "type": "library", + "description": "A Twig extension for Symfony String", + "keywords": ["twig", "html", "string", "unicode"], + "homepage": "https://twig.symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "require": { + "php": "^7.2.9", + "symfony/string": "^5.0@dev", + "twig/twig": "^2.4|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4@dev" + }, + "autoload": { + "psr-4" : { + "Twig\\Extra\\String\\" : "src/" + } + }, + "autoload-dev": { + "psr-4" : { + "Twig\\Extra\\String\\Tests\\" : "tests/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "2.12-dev" + } + } +} diff --git a/extra/string-extra/phpunit.xml.dist b/extra/string-extra/phpunit.xml.dist new file mode 100644 index 000000000..4b84ca9c2 --- /dev/null +++ b/extra/string-extra/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + + + + + ./tests/ + + + + + + ./ + + ./tests + ./vendor + + + + diff --git a/extra/string-extra/src/StringExtension.php b/extra/string-extra/src/StringExtension.php new file mode 100644 index 000000000..ae99d971f --- /dev/null +++ b/extra/string-extra/src/StringExtension.php @@ -0,0 +1,31 @@ +