GithubHelp home page GithubHelp logo

spatie / string Goto Github PK

View Code? Open in Web Editor NEW
560.0 16.0 25.0 118 KB

String handling evolved

Home Page: https://murze.be/2015/06/common-string-functions/

License: MIT License

PHP 100.00%
php string

string's Issues

Wrong example or description for "segment" method?

Why in description of method SEGMENT has two parameters, but one of the examples has three parameters? "->segment('/', 0, true)"

Method description:

/**
 * Get a segment from a string based on a delimiter.
 * Returns an empty string when the offset doesn't exist.
 * Use a negative index to start counting from the last element.
 * 
 * @param string $delimiter
 * @param int $index
 * 
 * @return \Spatie\String\String
 */
public function segment($delimiter, $index)    <-- 2 parameters

Example:
string('foo/bar/baz')->segment('/', 0, true); // baz <-- 3 parameters

Why do not use:
string('foo/bar/baz')->segment('/', -1); // baz

[Feature Request] Callback on the result of the explode

Hi,
Would it be a good idea to return $this from the explode and provide the possibility to use array_filter or array_map and other native feature on the array or simply a callback for the user defined action.

Usecase:

I have a string say

$sizeStr = "Nice shoes with Size= 12 ,13, 14 , 15, "; 

$filterCallback= function($item){
return true; // just example 
};
$parsedSize = \string($sizeStr)
->lastSegment('Size=')
->trim()
->explode(',')
->arrayFilter()
->arrayMap('trim')
->apply(function($data){

});

Would something like this be useful ?

Laravel 9 Compatibility

It looks like anahkiasen/underscore-php requires doctrine/inflector ^1.0, and Laravel 9 requires ^2.0 via illuminate/support

Is this functionality that should be pulled native into this package? Or is there an alternate package to use?

Related: #22 #23 #24

Anahkiasen/underscore-php Deprecated

I have started to receive warnings from composer that anahkiasen/underscore-php is now abandoned. No alternative for this package is provided, however Laravel's Str:: helpers provide some alternative functions.

It may be worth removing this dependency and directing people towards the Laravel helpers in the Illuminate\Support package?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.