flowchart LR
A[If I] --> B{could};
B -- Yes --> C[I would];
C --> D[Let it go, Surrender, Dislocate];
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ 'Lorem ipsum'|u.truncate(8, '...') }} | |
{# prints: Lorem... #} | |
{{ 'SymfonyStringWithTwig'|u.snake }} | |
{# prints: symfony_string_with_twig #} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\String\Slugger\AsciiSlugger; | |
$slugger = new AsciiSlugger(); | |
$slugger->slug('Стойността трябва', 'bg'); // 'Stoinostta-tryabva' | |
$slugger->slug('Αυτή η τιμή πρέπει', 'el'); // 'Avti-i-timi-prepi' | |
$slugger->slug('该变量的值应为', 'zh'); // 'gai-bian-liang-de-zhi-ying-wei' | |
$slugger->slug('Wôrķšƥáçè sèťtïñğš'); // 'Workspace-settings' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
u('FOO Bar')->folded(); // 'foo bar' | |
u('Die O\'Brian Straße')->folded(); // "die o'brian strasse" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$text =u('This is a déjà-vu situation.') | |
->trimEnd('.') | |
->replace('déjà-vu', 'jamais-vu') | |
->append('!'); | |
// $text = 'This is a jamais-vu situation!' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// usando funções do PHP | |
if ('.html' === substr($theString, -strlen('.html'))) { | |
// ... | |
} | |
// usando o componente String do Symfony | |
if (u($theString)->endsWith('.html')) { | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use function Symfony\Component\String\b; | |
use function Symfony\Component\String\u; | |
// both are equivalent | |
$content = b('hello'); | |
$content = new ByteString('hello'); | |
// both are equivalent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\String\ByteString; | |
use Symfony\Component\String\CodePointString; | |
use Symfony\Component\String\UnicodeString; | |
$content = new CodePointString('Hello world'); | |
$content = new UnicodeString('नमस्ते दुनिया'); | |
$content = new ByteString('さよなら'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/services.yaml | |
services: | |
# ... | |
App\HandlerCollection: | |
arguments: [!tagged_iterator app.handler, default_priority_method: 'calculateServicePriority'] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/services.yaml | |
services: | |
_instanceof: | |
App\Handler: | |
tags: | |
- { name: 'app.handler', priority: 20 } | |
App\HandlerCollection: | |
arguments: [!tagged_iterator app.handler] | |
NewerOlder