Download the PHP package kolyunya/string-processor without Composer

On this page you can find all versions of the php package kolyunya/string-processor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package string-processor

PHP string processing library

Status

Build Status Code Climate Latest Stable Version

Description

This library provides a collection of string processors.

Installation

This library is composer-enabled. The recommended way of using it in your project is to require it via composer.

composer require kolyunya/string-processor

Single processor usage

Basic usage

Each processor implements the ProcessorInterface which contains the process method:

/**
 * Processes a string and returns a processed version of the original string.
 * @param string $string A string to process.
 * @return string A processed version of the original string.
 */
public function process($string);

Construct a processor and run process($string) on it:

$processor = new Processor();
echo $processor->process($string);

Shorthand usage

You can also use a processor without even instantiating it. Each processor has a static run method.

/**
 * Processes a string and returns a processed version of the original string.
 * @param string $string A string to process.
 * @param object|array $parameters Parameters passed to the processor's constructor.
 * @return string A processed version of the original string.
 */
public static function run($string, $parameters = array());

You can pass parameters to the processor's constructor in the $parameters array. You can also pass a single parameter without wrapping it into an array.

echo KebabCaseFormatter::run('snake_case'); // Output: "snake-case"
echo Translator::run(
    'Лорем ипсум долор сит амет',
    new RuEnDictionary()
); // Output: "Lorem ipsum dolor sit amet"

Processors combination

Multiprocessor usage

There is a special processor (Multiprocessor) which allows you to combine multiple processors in one. Suppose you want to convert a string to an UPPER-KEBAB case. You can combine two processors using Multiprocessor to solve this problem.

$processor = new Multiprocessor([
    new KebabCaseFormatter(),
    new UpperCaseFormatter(),
]);
echo $processor->process('snake_case'); // Output: "SNAKE-CASE"
echo $processor->process('CamelCase'); // Output: "CAMEL-CASE"

The UpperCaseFormatter will be applied after the KebabCaseFormatter. Note that either the processors order does not matter in the first example, it actually matters in the second one.

Another common problem example is to generate URL slugs. A string should be purified from punctuation characters, converted to the kebab-case and transliterated. Combine the PunctuationStripper, the KebabCaseFormatter and the Translator using Multiprocessor.

$processor = new Multiprocessor([
    new RuEnTranslator(),
    new AlphabeticalPurifier(),
    new KebabCaseFormatter(),
]);
echo $processor->process('Лорем ипсум долор сит амет'); // Output: "lorem-ipsum-dolor-sit-amet"
echo $processor->process('Привет, Мир!'); // Output: "privet-mir"

Processors decoration

Each processor is a decorator. The ProcessorInterface contains the decorate method:

/**
 * Decorates supplied processor with the current processor.
 * @param ProcessorInterface $processor Processor to decorate.
 * @return ProcessorInterface Current processor.
 */
public function decorate(ProcessorInterface $processor);

That means that the above example can be implemented using processors decoration. The Multiprocessor usage is somewhat more readable though.

$processor =
(new RuEnTranslator())->decorate(
    (new KebabCaseFormatter())->decorate(
        (new PunctuationStripper())
    )
);
echo $processor->process('Лорем ипсум долор сит амет'); // Output: "lorem-ipsum-dolor-sit-amet"
echo $processor->process('Привет, Мир!'); // Output: "privet-mir"

Available processors

Currently the following processors are implemented:


All versions of string-processor with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3 <8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kolyunya/string-processor contains the following files

Loading the files please wait ....