Comments (8)
Alright! My 3rd point was about the fact that "substringing" is very common when manipulating strings, that's why I expected these methods to be merged in the main library, allowing the use an out-of-the-box swiss knife, requiring no config and no overriding.
I definitely think the package is useful, I just think it's hard to come up with terse method names that describe their behaviour. For example:
s('What are your plans today?')->substringAfterFirst('plans ');
// => "today"
// An equivalent using only core methods
s('What are your plans today?')->split('plans ')[1] ?: false
substringCount
// same as countSubstr in Stringy core
// Some of the other methods require a bit more aerobatics with just core,
// so I can see their benefit :)
The core library def has quite a few "substring" methods already :) But I think traits are the right way to go, letting people easily customize at will!
from stringy.
@TCB13 Agreed! Building off the core methods can get verbose too for some of those operations as the array primitives in PHP aren't great. Definitely appreciate the library :)
from stringy.
- Package renaming sounds fine, probably easier to remember as you said
- Join sounds good ๐
- I don't think SubStringy belongs in the core, and could probably be implemented as a Trait if you wanted a bit more flexibility :) TCB13/SubStringy#1 #87 (comment)
from stringy.
@bpolaszek I had this SubStringy discussion previously with @danielstjules - the first versions were actually a PR to this repo. There are also other "extensions" that follow this principle.
We're currently in the process of making SubStringy into a trait.
from stringy.
@bpolaszek @danielstjules TCB13/SubStringy is now a trait.
from stringy.
Hello @danielstjules @TCB13,
Alright! My 3rd point was about the fact that "substringing" is very common when manipulating strings, that's why I expected these methods to be merged in the main library, allowing the use an out-of-the-box swiss knife, requiring no config and no overriding.
But I understand your point, and the use of a trait is indeed a better approach that a vertical inheritance.
Do you want me to do a PR for points 1 & 2?
Thank you,
Ben
from stringy.
@TCB13 Awesome! :)
from stringy.
@danielstjules An equivalent using only core methods
those methods are hard on the eyes. This is one of the reasons why I added the substring methods. Easier to use specially when you use an IDE / sublime.
from stringy.
Related Issues (20)
- Multilingual pluralize and singularize HOT 1
- Title case is currently not title case HOT 1
- Wrong greek char corresponging HOT 2
- Idea: permutate() HOT 2
- [question] Finding a block HOT 1
- Add kebabfy method
- Small feature request: Humanize dash
- [question] Is Stringy compatible with multiline content? HOT 1
- Camelize doesn't work properly HOT 2
- Add replace() method
- Something like str_split?
- No reason for ั/ะช/ั/ะฌ to be in Bulgarian-specific array
- preg_replace(): Compilation failed: invalid range in character class at offset 12 HOT 3
- preg_replace(): Unknown modifier ']'
- README image is broken
- Allow hyphenated words option in titleize method. HOT 3
- Is this repository unmaintained? HOT 13
- ็้ผ
- Line break normalization
- PHP 8.1 compatibility HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stringy.