mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-01-29 10:38:15 +01:00
Create gh-pages branch via GitHub
This commit is contained in:
commit
00134eb8b6
847
index.html
Normal file
847
index.html
Normal file
@ -0,0 +1,847 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<title>Stringy by danielstjules</title>
|
||||
|
||||
<link rel="stylesheet" href="stylesheets/styles.css">
|
||||
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1>Stringy</h1>
|
||||
<p>A PHP string manipulation library with multibyte support</p>
|
||||
|
||||
<p class="view"><a href="https://github.com/danielstjules/Stringy">View the Project on GitHub <small>danielstjules/Stringy</small></a></p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li><a href="https://github.com/danielstjules/Stringy/zipball/master">Download <strong>ZIP File</strong></a></li>
|
||||
<li><a href="https://github.com/danielstjules/Stringy/tarball/master">Download <strong>TAR Ball</strong></a></li>
|
||||
<li><a href="https://github.com/danielstjules/Stringy">View On <strong>GitHub</strong></a></li>
|
||||
</ul>
|
||||
</header>
|
||||
<section>
|
||||
<h1>
|
||||
<a name="stringy" class="anchor" href="#stringy"><span class="octicon octicon-link"></span></a>Stringy</h1>
|
||||
|
||||
<p>A PHP library with a variety of string manipulation functions with multibyte support. Offers both OO method chaining and a procedural-style static wrapper. Inspired by underscore.string.js.</p>
|
||||
|
||||
<p>Note: The methods listed below are subject to change until we reach a 1.0.0 release.</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="#requiringloading">Requiring/Loading</a></li>
|
||||
<li><a href="#oo-and-procedural">OO and Procedural</a></li>
|
||||
<li>
|
||||
<a href="#methods">Methods</a>
|
||||
|
||||
<ul>
|
||||
<li><a href="#at">at</a></li>
|
||||
<li><a href="#camelize">camelize</a></li>
|
||||
<li><a href="#collapsewhitespace">collapseWhitespace</a></li>
|
||||
<li><a href="#contains">contains</a></li>
|
||||
<li><a href="#create">create</a></li>
|
||||
<li><a href="#dasherize">dasherize</a></li>
|
||||
<li><a href="#endswith">endsWith</a></li>
|
||||
<li><a href="#ensureleft">ensureLeft</a></li>
|
||||
<li><a href="#ensureright">ensureRight</a></li>
|
||||
<li><a href="#first">first</a></li>
|
||||
<li><a href="#humanize">humanize</a></li>
|
||||
<li><a href="#insert">insert</a></li>
|
||||
<li><a href="#isalpha">isAlpha</a></li>
|
||||
<li><a href="#isalphanumeric">isAlphanumeric</a></li>
|
||||
<li><a href="#isblank">isBlank</a></li>
|
||||
<li><a href="#islowercase">isLowerCase</a></li>
|
||||
<li><a href="#isuppercase">isUpperCase</a></li>
|
||||
<li><a href="#last">last</a></li>
|
||||
<li><a href="#length">length</a></li>
|
||||
<li><a href="#longestcommonprefix">longestCommonPrefix</a></li>
|
||||
<li><a href="#longestcommonsuffix">longestCommonSuffix</a></li>
|
||||
<li><a href="#longestcommonsubstring">longestCommonSubstring</a></li>
|
||||
<li><a href="#lowercasefirst">lowerCaseFirst</a></li>
|
||||
<li><a href="#pad">pad</a></li>
|
||||
<li><a href="#padboth">padBoth</a></li>
|
||||
<li><a href="#padleft">padLeft</a></li>
|
||||
<li><a href="#padright">padRight</a></li>
|
||||
<li><a href="#removeleft">removeLeft</a></li>
|
||||
<li><a href="#removeright">removeRight</a></li>
|
||||
<li><a href="#reverse">reverse</a></li>
|
||||
<li><a href="#safetruncate">safeTruncate</a></li>
|
||||
<li><a href="#shuffle">shuffle</a></li>
|
||||
<li><a href="#slugify">slugify</a></li>
|
||||
<li><a href="#standardize">standardize</a></li>
|
||||
<li><a href="#startswith">startsWith</a></li>
|
||||
<li><a href="#substr">substr</a></li>
|
||||
<li><a href="#surround">surround</a></li>
|
||||
<li><a href="#swapcase">swapCase</a></li>
|
||||
<li><a href="#tidy">tidy</a></li>
|
||||
<li><a href="#titleize">titleize</a></li>
|
||||
<li><a href="#tospaces">toSpaces</a></li>
|
||||
<li><a href="#totabs">toTabs</a></li>
|
||||
<li><a href="#trim">trim</a></li>
|
||||
<li><a href="#truncate">truncate</a></li>
|
||||
<li><a href="#underscored">underscored</a></li>
|
||||
<li><a href="#uppercamelize">upperCamelize</a></li>
|
||||
<li><a href="#uppercasefirst">upperCaseFirst</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#tests">Tests</a></li>
|
||||
<li><a href="#license">License</a></li>
|
||||
</ul><h2>
|
||||
<a name="requiringloading" class="anchor" href="#requiringloading"><span class="octicon octicon-link"></span></a>Requiring/Loading</h2>
|
||||
|
||||
<p>If you're using Composer to manage dependencies, you can include the following in your composer.json file:</p>
|
||||
|
||||
<pre><code>"require": {
|
||||
"danielstjules/stringy": "dev-master"
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
<p>Then, after running <code>composer update</code> or <code>php composer.phar update</code>, you can load the class using Composer's autoloading:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">require</span> <span class="s1">'vendor/autoload.php'</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
|
||||
<p>Otherwise, you can simply require the file directly:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">require_once</span> <span class="s1">'path/to/Stringy/src/Stringy/Stringy.php'</span><span class="p">;</span>
|
||||
<span class="c1">// or</span>
|
||||
<span class="k">require_once</span> <span class="s1">'path/to/Stringy/src/Stringy/StaticStringy.php'</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
|
||||
<p>And in either case, I'd suggest using an alias.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">use</span> <span class="nx">Stringy\Stringy</span> <span class="k">as</span> <span class="nx">S</span><span class="p">;</span>
|
||||
<span class="c1">// or</span>
|
||||
<span class="k">use</span> <span class="nx">Stringy\StaticStringy</span> <span class="k">as</span> <span class="nx">S</span><span class="p">;</span>
|
||||
</pre></div>
|
||||
|
||||
<h2>
|
||||
<a name="oo-and-procedural" class="anchor" href="#oo-and-procedural"><span class="octicon octicon-link"></span></a>OO and Procedural</h2>
|
||||
|
||||
<p>The library offers both OO method chaining with <code>Stringy\Stringy</code>, as well as
|
||||
procedural-style static method calls with <code>Stringy\StaticStringy</code>. An example
|
||||
of the former is the following:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">use</span> <span class="nx">Stringy\Stringy</span> <span class="k">as</span> <span class="nx">S</span><span class="p">;</span>
|
||||
<span class="k">echo</span> <span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s2">"Fòô Bàř"</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">collapseWhitespace</span><span class="p">()</span><span class="o">-></span><span class="na">swapCase</span><span class="p">();</span> <span class="c1">// 'fÒÔ bÀŘ'</span>
|
||||
</pre></div>
|
||||
|
||||
<p><code>Stringy\Stringy</code> contains a __toString() method, which returns the current
|
||||
string when the object is used in a string context. Its $str property is also
|
||||
public, and can be accessed directly if required, ie: <code>S::create('foo')->str // 'foo'</code></p>
|
||||
|
||||
<p>Using the static wrapper, an alternative is the following:</p>
|
||||
|
||||
<div class="highlight"><pre><span class="k">use</span> <span class="nx">Stringy\StaticStringy</span> <span class="k">as</span> <span class="nx">S</span><span class="p">;</span>
|
||||
<span class="nv">$string</span> <span class="o">=</span> <span class="nx">S</span><span class="o">::</span><span class="na">collapseWhitespace</span><span class="p">(</span><span class="s2">"Fòô Bàř"</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span>
|
||||
<span class="k">echo</span> <span class="nx">S</span><span class="o">::</span><span class="na">swapCase</span><span class="p">(</span><span class="nv">$string</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fÒÔ bÀŘ''</span>
|
||||
</pre></div>
|
||||
|
||||
<h2>
|
||||
<a name="methods" class="anchor" href="#methods"><span class="octicon octicon-link"></span></a>Methods</h2>
|
||||
|
||||
<p>In the list below, any static method other than S::create refers to a
|
||||
method in Stringy\StaticStringy. For all others, they're found in Stringy\Stringy.</p>
|
||||
|
||||
<p><em>Note: If $encoding is not given, it defaults to mb_internal_encoding().</em></p>
|
||||
|
||||
<h5>
|
||||
<a name="at" class="anchor" href="#at"><span class="octicon octicon-link"></span></a>at</h5>
|
||||
|
||||
<p>$stringy->at(int $index)</p>
|
||||
|
||||
<p>S::substr(int $index [, string $encoding ])</p>
|
||||
|
||||
<p>Gets the character of $str at $index, with indexes starting at 0.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">at</span><span class="p">(</span><span class="mi">6</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">at</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'ř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="camelize" class="anchor" href="#camelize"><span class="octicon octicon-link"></span></a>camelize</h5>
|
||||
|
||||
<p>$stringy->camelize();</p>
|
||||
|
||||
<p>S::camelize(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns a camelCase version of a supplied string, with multibyte support.
|
||||
Trims surrounding spaces, capitalizes letters following digits, spaces,
|
||||
dashes and underscores, and removes spaces, dashes, underscores.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Camel-Case'</span><span class="p">)</span><span class="o">-></span><span class="na">camelize</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">camelize</span><span class="p">(</span><span class="s1">'Camel-Case'</span><span class="p">);</span> <span class="c1">// 'camelCase'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="collapsewhitespace" class="anchor" href="#collapsewhitespace"><span class="octicon octicon-link"></span></a>collapseWhitespace</h5>
|
||||
|
||||
<p>$stringy->collapseWhitespace()</p>
|
||||
|
||||
<p>S::collapseWhitespace(string $str)</p>
|
||||
|
||||
<p>Trims the string and replaces consecutive whitespace characters with a
|
||||
single space. This inclues tabs and newline characters.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">' Ο συγγραφέας '</span><span class="p">)</span><span class="o">-></span><span class="na">collapseWhitespace</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">collapseWhitespace</span><span class="p">(</span><span class="s1">' Ο συγγραφέας '</span><span class="p">);</span> <span class="c1">// 'Ο συγγραφέας'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="contains" class="anchor" href="#contains"><span class="octicon octicon-link"></span></a>contains</h5>
|
||||
|
||||
<p>$stringy->contains(string $needle)</p>
|
||||
|
||||
<p>S::contains(string $haystack, string $needle [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $haystack contains $needle, false otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Ο συγγραφέας είπε'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">contains</span><span class="p">(</span><span class="s1">'συγγραφέας'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">contains</span><span class="p">(</span><span class="s1">'Ο συγγραφέας είπε'</span><span class="p">,</span> <span class="s1">'συγγραφέας'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="create" class="anchor" href="#create"><span class="octicon octicon-link"></span></a>create</h5>
|
||||
|
||||
<p>$stringy = S::create(string $str, [, $encoding ])</p>
|
||||
|
||||
<p>Creates a Stringy object and assigns both str and encoding properties
|
||||
the supplied values. If $encoding is not specified, it defaults to
|
||||
mb_internal_encoding(). It then returns the instantiated object.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fòô bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="dasherize" class="anchor" href="#dasherize"><span class="octicon octicon-link"></span></a>dasherize</h5>
|
||||
|
||||
<p>$stringy->dasherize();</p>
|
||||
|
||||
<p>S::dasherize(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns a lowercase and trimmed string seperated by dashes, with
|
||||
multibyte support. Dashes are inserted before uppercase characters
|
||||
(with the exception of the first character of the string), and in place
|
||||
of spaces as well as underscores.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'TestDCase'</span><span class="p">)</span><span class="o">-></span><span class="na">dasherize</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">dasherize</span><span class="p">(</span><span class="s1">'TestDCase'</span><span class="p">);</span> <span class="c1">// 'test-d-case'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="endswith" class="anchor" href="#endswith"><span class="octicon octicon-link"></span></a>endsWith</h5>
|
||||
|
||||
<p>$stringy->endsWith(string $substring [, boolean $caseSensitive = true ])</p>
|
||||
|
||||
<p>S::endsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])</p>
|
||||
|
||||
<p>Returns true if the string $str ends with $substring, false otherwise.
|
||||
By default, the comparison is case-sensitive, but can be made insensitive
|
||||
by setting $caseSensitive to false.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'FÒÔ bàřs'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">endsWith</span><span class="p">(</span><span class="s1">'àřs'</span><span class="p">,</span> <span class="k">true</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">endsWith</span><span class="p">(</span><span class="s1">'FÒÔ bàřs'</span><span class="p">,</span> <span class="s1">'àřs'</span><span class="p">,</span> <span class="k">true</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="ensureleft" class="anchor" href="#ensureleft"><span class="octicon octicon-link"></span></a>ensureLeft</h5>
|
||||
|
||||
<p>$stringy->ensureLeft(string $substring)</p>
|
||||
|
||||
<p>S::ensureLeft(string $substring [, string $encoding ])</p>
|
||||
|
||||
<p>Ensures that $str begins with $substring.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'foobar'</span><span class="p">)</span><span class="o">-></span><span class="na">ensureLeft</span><span class="p">(</span><span class="s1">'http://'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">ensureLeft</span><span class="p">(</span><span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'http://'</span><span class="p">);</span> <span class="c1">// 'http://foobar'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="ensureright" class="anchor" href="#ensureright"><span class="octicon octicon-link"></span></a>ensureRight</h5>
|
||||
|
||||
<p>$stringy->ensureRight(string $substring)</p>
|
||||
|
||||
<p>S::ensureRight(string $substring [, string $encoding ])</p>
|
||||
|
||||
<p>Ensures that $str ends with $substring.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'foobar'</span><span class="p">)</span><span class="o">-></span><span class="na">ensureRight</span><span class="p">(</span><span class="s1">'.com'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">ensureRight</span><span class="p">(</span><span class="s1">'foobar'</span><span class="p">,</span> <span class="s1">'.com'</span><span class="p">);</span> <span class="c1">// 'foobar.com'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="first" class="anchor" href="#first"><span class="octicon octicon-link"></span></a>first</h5>
|
||||
|
||||
<p>$stringy->first(int $n)</p>
|
||||
|
||||
<p>S::first(int $n [, string $encoding ])</p>
|
||||
|
||||
<p>Gets the first $n characters of $str.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">first</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">first</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fòô'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="humanize" class="anchor" href="#humanize"><span class="octicon octicon-link"></span></a>humanize</h5>
|
||||
|
||||
<p>$stringy->humanize()</p>
|
||||
|
||||
<p>S::humanize(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Capitalizes the first word of a string, replaces underscores with spaces,
|
||||
and strips '_id'.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'author_id'</span><span class="p">)</span><span class="o">-></span><span class="na">humanize</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">humanize</span><span class="p">(</span><span class="s1">'author_id'</span><span class="p">);</span> <span class="c1">// 'Author'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="insert" class="anchor" href="#insert"><span class="octicon octicon-link"></span></a>insert</h5>
|
||||
|
||||
<p>$stringy->insert(int $index, string $substring)</p>
|
||||
|
||||
<p>S::insert(string $str, int $index, string $substring [, string $encoding ])</p>
|
||||
|
||||
<p>Inserts $substring into $str at the $index provided.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bà'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">insert</span><span class="p">(</span><span class="s1">'ř'</span><span class="p">,</span> <span class="mi">6</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">insert</span><span class="p">(</span><span class="s1">'fòô bà'</span><span class="p">,</span> <span class="s1">'ř'</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fòô bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="isalpha" class="anchor" href="#isalpha"><span class="octicon octicon-link"></span></a>isAlpha</h5>
|
||||
|
||||
<p>$stringy->isAlpha()</p>
|
||||
|
||||
<p>S::isAlpha(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $str contains only alphabetic chars, false otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'丹尼爾'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">isAlpha</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">isAlpha</span><span class="p">(</span><span class="s1">'丹尼爾'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="isalphanumeric" class="anchor" href="#isalphanumeric"><span class="octicon octicon-link"></span></a>isAlphanumeric</h5>
|
||||
|
||||
<p>$stringy->isAlphanumeric()</p>
|
||||
|
||||
<p>S::isAlphanumeric(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $str contains only alphabetic and numeric chars, false
|
||||
otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'دانيال1'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">isAlphanumeric</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">isAlphanumeric</span><span class="p">(</span><span class="s1">'دانيال1'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="isblank" class="anchor" href="#isblank"><span class="octicon octicon-link"></span></a>isBlank</h5>
|
||||
|
||||
<p>$stringy->isBlank()</p>
|
||||
|
||||
<p>S::isBlank(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $str contains only whitespace chars, false otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s2">"</span><span class="se">\n\t</span><span class="s2"> \v\f"</span><span class="p">)</span><span class="o">-></span><span class="na">isBlank</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">isBlank</span><span class="p">(</span><span class="s2">"</span><span class="se">\n\t</span><span class="s2"> \v\f"</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="islowercase" class="anchor" href="#islowercase"><span class="octicon octicon-link"></span></a>isLowerCase</h5>
|
||||
|
||||
<p>$stringy->isLowerCase()</p>
|
||||
|
||||
<p>S::isLowerCase(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $str contains only lower case chars, false otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">isLowerCase</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">isLowerCase</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="isuppercase" class="anchor" href="#isuppercase"><span class="octicon octicon-link"></span></a>isUpperCase</h5>
|
||||
|
||||
<p>$stringy->isUpperCase()</p>
|
||||
|
||||
<p>S::isUpperCase(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns true if $str contains only upper case chars, false otherwise.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'FÒÔBÀŘ'</span><span class="p">,,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">isUpperCase</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">isUpperCase</span><span class="p">(</span><span class="s1">'FÒÔBÀŘ'</span><span class="p">,,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="last" class="anchor" href="#last"><span class="octicon octicon-link"></span></a>last</h5>
|
||||
|
||||
<p>$stringy->last(int $n)</p>
|
||||
|
||||
<p>S::last(int $n [, string $encoding ])</p>
|
||||
|
||||
<p>Gets the last $n characters of $str.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">last</span><span class="p">(</span><span class="mi">3</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">last</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="length" class="anchor" href="#length"><span class="octicon octicon-link"></span></a>length</h5>
|
||||
|
||||
<p>$stringy->length()</p>
|
||||
|
||||
<p>S::length(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns the length of $str. An alias for PHP's mb_strlen() function.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">length</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">length</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 7</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="longestcommonprefix" class="anchor" href="#longestcommonprefix"><span class="octicon octicon-link"></span></a>longestCommonPrefix</h5>
|
||||
|
||||
<p>$stringy->longestCommonPrefix(string $otherStr)</p>
|
||||
|
||||
<p>S::longestCommonPrefix(string $str, string $otherStr [, $encoding ])</p>
|
||||
|
||||
<p>Finds the longest common prefix between $str and $otherStr.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bar'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">longestCommonPrefix</span><span class="p">(</span><span class="s1">'fòr bar'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">longestCommonPrefix</span><span class="p">(</span><span class="s1">'fòô bar'</span><span class="p">,</span> <span class="s1">'fòr bar'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fò'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="longestcommonsuffix" class="anchor" href="#longestcommonsuffix"><span class="octicon octicon-link"></span></a>longestCommonSuffix</h5>
|
||||
|
||||
<p>$stringy->longestCommonSuffix(string $otherStr)</p>
|
||||
|
||||
<p>S::longestCommonSuffix(string $str, string $otherStr [, $encoding ])</p>
|
||||
|
||||
<p>Finds the longest common suffix between $str and $otherStr.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">longestCommonSuffix</span><span class="p">(</span><span class="s1">'fòr bàř'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">longestCommonSuffix</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'fòr bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// ' bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="longestcommonsubstring" class="anchor" href="#longestcommonsubstring"><span class="octicon octicon-link"></span></a>longestCommonSubstring</h5>
|
||||
|
||||
<p>$stringy->longestCommonSubstring(string $otherStr)</p>
|
||||
|
||||
<p>S::longestCommonSubstring(string $str, string $otherStr [, $encoding ])</p>
|
||||
|
||||
<p>Finds the longest common substring between $str and $otherStr. In the
|
||||
case of ties, returns that which occurs first.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">)</span><span class="o">-></span><span class="na">longestCommonSubstring</span><span class="p">(</span><span class="s1">'boo far'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">longestCommonSubstring</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">,</span> <span class="s1">'boo far'</span><span class="p">);</span> <span class="c1">// 'oo '</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="lowercasefirst" class="anchor" href="#lowercasefirst"><span class="octicon octicon-link"></span></a>lowerCaseFirst</h5>
|
||||
|
||||
<p>$stringy->lowerCaseFirst();</p>
|
||||
|
||||
<p>S::lowerCaseFirst(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Converts the first character of the supplied string to lower case, with
|
||||
support for multibyte strings.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Σ test'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">lowerCaseFirst</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">lowerCaseFirst</span><span class="p">(</span><span class="s1">'Σ test'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'σ test'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="pad" class="anchor" href="#pad"><span class="octicon octicon-link"></span></a>pad</h5>
|
||||
|
||||
<p>$stringy->pad(int $length [, string $padStr = ' ' [, string $padType = 'right' ]])</p>
|
||||
|
||||
<p>S::pad(string $str , int $length [, string $padStr = ' ' [, string $padType = 'right' [, string $encoding ]]])</p>
|
||||
|
||||
<p>Pads a string to a given length with another string. If length is less
|
||||
than or equal to the length of $str, then no padding takes places. The
|
||||
default string used for padding is a space, and the default type (one of
|
||||
'left', 'right', 'both') is 'right'. Throws an exception if $padType
|
||||
isn't one of those 3 values.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">pad</span><span class="p">(</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">'¬ø'</span><span class="p">,</span> <span class="s1">'left'</span><span class="p">,);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">pad</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">'¬ø'</span><span class="p">,</span> <span class="s1">'left'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// '¬ø¬fòô bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="padboth" class="anchor" href="#padboth"><span class="octicon octicon-link"></span></a>padBoth</h5>
|
||||
|
||||
<p>$stringy->padBoth(int $length [, string $padStr = ' ' ])</p>
|
||||
|
||||
<p>S::padBoth(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])</p>
|
||||
|
||||
<p>Returns a new string of a given length such that both sides of the string
|
||||
string are padded. Alias for pad($str, $length, $padStr, 'both', $encoding)</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">)</span><span class="o">-></span><span class="na">padBoth</span><span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="s1">' '</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">padBoth</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="s1">' '</span><span class="p">);</span> <span class="c1">// ' foo bar '</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="padleft" class="anchor" href="#padleft"><span class="octicon octicon-link"></span></a>padLeft</h5>
|
||||
|
||||
<p>$stringy->padLeft(int $length [, string $padStr = ' ' ])</p>
|
||||
|
||||
<p>S::padLeft(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])</p>
|
||||
|
||||
<p>Returns a new string of a given length such that the beginning of the
|
||||
string is padded. Alias for pad($str, $length, $padStr, 'left', $encoding)</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="nv">$str</span><span class="p">,</span> <span class="nv">$encoding</span><span class="p">)</span><span class="o">-></span><span class="na">padLeft</span><span class="p">(</span><span class="nv">$length</span><span class="p">,</span> <span class="nv">$padStr</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">padLeft</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">,</span> <span class="mi">9</span><span class="p">,</span> <span class="s1">' '</span><span class="p">);</span> <span class="c1">// ' foo bar'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="padright" class="anchor" href="#padright"><span class="octicon octicon-link"></span></a>padRight</h5>
|
||||
|
||||
<p>$stringy->padRight(int $length [, string $padStr = ' ' ])</p>
|
||||
|
||||
<p>S::padRight(string $str , int $length [, string $padStr = ' ' [, string $encoding ]])</p>
|
||||
|
||||
<p>Returns a new string of a given length such that the end of the string is
|
||||
padded. Alias for pad($str, $length, $padStr, 'right', $encoding)</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">)</span><span class="o">-></span><span class="na">padRight</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="s1">'_*'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">padRight</span><span class="p">(</span><span class="s1">'foo bar'</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="s1">'_*'</span><span class="p">);</span> <span class="c1">// 'foo bar_*_'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="removeleft" class="anchor" href="#removeleft"><span class="octicon octicon-link"></span></a>removeLeft</h5>
|
||||
|
||||
<p>$stringy->removeLeft(string $substring)</p>
|
||||
|
||||
<p>S::removeLeft(string $str, string $substring [, string $encoding ])</p>
|
||||
|
||||
<p>Removes the prefix $substring if present.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">removeLeft</span><span class="p">(</span><span class="s1">'fòô '</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">removeLeft</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'fòô '</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="removeright" class="anchor" href="#removeright"><span class="octicon octicon-link"></span></a>removeRight</h5>
|
||||
|
||||
<p>$stringy->removeRight(string $substring)</p>
|
||||
|
||||
<p>S::removeRight(string $str, string $substring [, string $encoding ])</p>
|
||||
|
||||
<p>Removes the suffix $substring if present.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">removeRight</span><span class="p">(</span><span class="s1">' bàř'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">removeRight</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">' bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'fòô'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="reverse" class="anchor" href="#reverse"><span class="octicon octicon-link"></span></a>reverse</h5>
|
||||
|
||||
<p>$stringy->reverse()</p>
|
||||
|
||||
<p>S::reverse(string $str, [, string $encoding ])</p>
|
||||
|
||||
<p>Reverses a string. A multibyte version of strrev.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">reverse</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">reverse</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'řàb ôòf'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="safetruncate" class="anchor" href="#safetruncate"><span class="octicon octicon-link"></span></a>safeTruncate</h5>
|
||||
|
||||
<p>$stringy->safeTruncate(int $length, [, string $substring = '' ])</p>
|
||||
|
||||
<p>S::safeTruncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])</p>
|
||||
|
||||
<p>Truncates the string to a given length, while ensuring that it does not
|
||||
chop words. If $substring is provided, and truncating occurs, the string
|
||||
is further truncated so that the substring may be appended without
|
||||
exceeding the desired length.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'What are your plans today?'</span><span class="p">)</span><span class="o">-></span><span class="na">safeTruncate</span><span class="p">(</span><span class="mi">22</span><span class="p">,</span> <span class="s1">'...'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">safeTruncate</span><span class="p">(</span><span class="s1">'What are your plans today?'</span><span class="p">,</span> <span class="mi">22</span><span class="p">,</span> <span class="s1">'...'</span><span class="p">);</span> <span class="c1">// 'What are your plans...'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="shuffle" class="anchor" href="#shuffle"><span class="octicon octicon-link"></span></a>shuffle</h5>
|
||||
|
||||
<p>$stringy->shuffle()</p>
|
||||
|
||||
<p>S::shuffle(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>A multibyte str_shuffle function. It randomizes the order of characters
|
||||
in a string.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">shuffle</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">shuffle</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span> <span class="c1">// 'àôřb òf'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="slugify" class="anchor" href="#slugify"><span class="octicon octicon-link"></span></a>slugify</h5>
|
||||
|
||||
<p>$stringy->slugify()</p>
|
||||
|
||||
<p>S::slugify(string $str)</p>
|
||||
|
||||
<p>Converts the supplied text into an URL slug. This includes replacing
|
||||
non-ASCII characters with their closest ASCII equivalents, removing
|
||||
non-alphanumeric and non-ASCII characters, and replacing whitespace with
|
||||
dashes. The string is also converted to lowercase.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Using strings like fòô bàř'</span><span class="p">)</span><span class="o">-></span><span class="na">slugify</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">slugify</span><span class="p">(</span><span class="s1">'Using strings like fòô bàř'</span><span class="p">)</span> <span class="c1">// 'using-strings-like-foo-bar'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="standardize" class="anchor" href="#standardize"><span class="octicon octicon-link"></span></a>standardize</h5>
|
||||
|
||||
<p>$stringy->standardize()</p>
|
||||
|
||||
<p>S::standardize(string $str)</p>
|
||||
|
||||
<p>Converts some non-ASCII characters to their closest ASCII counterparts.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">)</span><span class="o">-></span><span class="na">standardize</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">standardize</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">);</span> <span class="c1">// 'foo bar'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="startswith" class="anchor" href="#startswith"><span class="octicon octicon-link"></span></a>startsWith</h5>
|
||||
|
||||
<p>$stringy->startsWith(string $substring [, boolean $caseSensitive = true ])</p>
|
||||
|
||||
<p>S::startsWith(string $str, string $substring [, boolean $caseSensitive = true [, string $encoding ]])</p>
|
||||
|
||||
<p>Returns true if the string $str begins with $substring, false otherwise.
|
||||
By default, the comparison is case-sensitive, but can be made insensitive
|
||||
by setting $caseSensitive to false.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'FÒÔ bàřs'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">startsWith</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="k">false</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">startsWith</span><span class="p">(</span><span class="s1">'FÒÔ bàřs'</span><span class="p">,</span> <span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="k">false</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// true</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="substr" class="anchor" href="#substr"><span class="octicon octicon-link"></span></a>substr</h5>
|
||||
|
||||
<p>$stringy->substr(int $start [, int $length ])</p>
|
||||
|
||||
<p>S::substr(string $str, int $start [, int $length [, string $encoding ]])</p>
|
||||
|
||||
<p>Gets the substring of $str beginning at $start with the specified $length.
|
||||
It differs from the mb_substr() function in that providing a $length of
|
||||
null will return the rest of the string, rather than an empty string.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">substr</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">substr</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'ô b'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="surround" class="anchor" href="#surround"><span class="octicon octicon-link"></span></a>surround</h5>
|
||||
|
||||
<p>$stringy->surround(string $substring)</p>
|
||||
|
||||
<p>S::surround(string $str, string $substring)</p>
|
||||
|
||||
<p>Surrounds a string with the given substring.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">' ͜ '</span><span class="p">)</span><span class="o">-></span><span class="na">surround</span><span class="p">(</span><span class="s1">'ʘ'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">surround</span><span class="p">(</span><span class="s1">' ͜ '</span><span class="p">,</span> <span class="s1">'ʘ'</span><span class="p">);</span> <span class="c1">// 'ʘ ͜ ʘ'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="swapcase" class="anchor" href="#swapcase"><span class="octicon octicon-link"></span></a>swapCase</h5>
|
||||
|
||||
<p>$stringy->swapCase();</p>
|
||||
|
||||
<p>S::swapCase(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns a case swapped version of a string.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Ντανιλ'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">swapCase</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">swapCase</span><span class="p">(</span><span class="s1">'Ντανιλ'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'νΤΑΝΙΛ'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="tidy" class="anchor" href="#tidy"><span class="octicon octicon-link"></span></a>tidy</h5>
|
||||
|
||||
<p>$stringy->tidy()</p>
|
||||
|
||||
<p>S::tidy(string $str)</p>
|
||||
|
||||
<p>Replaces smart quotes, ellipsis characters, and dashes from Windows-1252
|
||||
(and commonly used in Word documents) with their ASCII equivalents.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'“I see…”'</span><span class="p">)</span><span class="o">-></span><span class="na">tidy</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">tidy</span><span class="p">(</span><span class="s1">'“I see…”'</span><span class="p">);</span> <span class="c1">// '"I see..."'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="titleize" class="anchor" href="#titleize"><span class="octicon octicon-link"></span></a>titleize</h5>
|
||||
|
||||
<p>$stringy->titleize([ string $encoding ])</p>
|
||||
|
||||
<p>S::titleize(string $str [, array $ignore [, string $encoding ]])</p>
|
||||
|
||||
<p>Capitalizes the first letter of each word in a string, after trimming.
|
||||
Ignores the case of other letters, allowing for the use of acronyms.
|
||||
Also accepts an array, $ignore, allowing you to list words not to be
|
||||
capitalized.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nv">$ignore</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span><span class="s1">'at'</span><span class="p">,</span> <span class="s1">'by'</span><span class="p">,</span> <span class="s1">'for'</span><span class="p">,</span> <span class="s1">'in'</span><span class="p">,</span> <span class="s1">'of'</span><span class="p">,</span> <span class="s1">'on'</span><span class="p">,</span> <span class="s1">'out'</span><span class="p">,</span> <span class="s1">'to'</span><span class="p">,</span> <span class="s1">'the'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'i like to watch DVDs at home'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">titleize</span><span class="p">(</span><span class="nv">$ignore</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">titleize</span><span class="p">(</span><span class="s1">'i like to watch DVDs at home'</span><span class="p">,</span> <span class="nv">$ignore</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span>
|
||||
<span class="c1">// 'I Like to Watch DVDs at Home'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="tospaces" class="anchor" href="#tospaces"><span class="octicon octicon-link"></span></a>toSpaces</h5>
|
||||
|
||||
<p>$stringy->toSpaces([ tabLength = 4 ])</p>
|
||||
|
||||
<p>S::toSpaces(string $str, [, int $tabLength = 4 ])</p>
|
||||
|
||||
<p>Converts each tab in a string to some number of spaces, as defined by
|
||||
$tabLength. By default, each tab is converted to 4 consecutive spaces.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">' String speech = "Hi"'</span><span class="p">)</span><span class="o">-></span><span class="na">toSpaces</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">toSpaces</span><span class="p">(</span><span class="s1">' String speech = "Hi"'</span><span class="p">)</span> <span class="c1">// ' String speech = "Hi"'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="totabs" class="anchor" href="#totabs"><span class="octicon octicon-link"></span></a>toTabs</h5>
|
||||
|
||||
<p>$stringy->toTabs([ tabLength = 4 ])</p>
|
||||
|
||||
<p>S::toTabs(string $str, [, int $tabLength = 4 ])</p>
|
||||
|
||||
<p>Converts each occurence of some consecutive number of spaces, as defined
|
||||
by $tabLength, to a tab. By default, each 4 consecutive spaces are
|
||||
converted to a tab.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">' fòô bàř'</span><span class="p">)</span><span class="o">-></span><span class="na">toTabs</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">toTabs</span><span class="p">(</span><span class="s1">' fòô bàř'</span><span class="p">)</span> <span class="c1">// ' fòô bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="trim" class="anchor" href="#trim"><span class="octicon octicon-link"></span></a>trim</h5>
|
||||
|
||||
<p>$stringy->trim()</p>
|
||||
|
||||
<p>S::trim(string $str)</p>
|
||||
|
||||
<p>Trims $str. An alias for PHP's trim() function.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'fòô bàř'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">trim</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">trim</span><span class="p">(</span><span class="s1">' fòô bàř '</span><span class="p">)</span> <span class="c1">// 'fòô bàř'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="truncate" class="anchor" href="#truncate"><span class="octicon octicon-link"></span></a>truncate</h5>
|
||||
|
||||
<p>$stringy->truncate(int $length, [, string $substring = '' ])</p>
|
||||
|
||||
<p>S::truncate(string $str, int $length, [, string $substring = '' [, string $encoding ]])</p>
|
||||
|
||||
<p>Truncates $str to a given length. If $substring is provided, and
|
||||
truncating occurs, the string is further truncated so that the substring
|
||||
may be appended without exceeding the desired length.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'What are your plans today?'</span><span class="p">)</span><span class="o">-></span><span class="na">safeTruncate</span><span class="p">(</span><span class="mi">19</span><span class="p">,</span> <span class="s1">'...'</span><span class="p">);</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">safeTruncate</span><span class="p">(</span><span class="s1">'What are your plans today?'</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="s1">'...'</span><span class="p">);</span> <span class="c1">// 'What are your pl...'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="underscored" class="anchor" href="#underscored"><span class="octicon octicon-link"></span></a>underscored</h5>
|
||||
|
||||
<p>$stringy->underscored();</p>
|
||||
|
||||
<p>S::underscored(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns a lowercase and trimmed string seperated by underscores, with
|
||||
multibyte support. Underscores are inserted before uppercase characters
|
||||
(with the exception of the first character of the string), and in place
|
||||
of spaces as well as dashes.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'TestUCase'</span><span class="p">)</span><span class="o">-></span><span class="na">underscored</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">underscored</span><span class="p">(</span><span class="s1">'TestUCase'</span><span class="p">);</span> <span class="c1">// 'test_u_case'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="uppercamelize" class="anchor" href="#uppercamelize"><span class="octicon octicon-link"></span></a>upperCamelize</h5>
|
||||
|
||||
<p>$stringy->upperCamelize();</p>
|
||||
|
||||
<p>S::upperCamelize(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Returns an UpperCamelCase version of a supplied string, with multibyte
|
||||
support. Trims surrounding spaces, capitalizes letters following digits,
|
||||
spaces, dashes and underscores, and removes spaces, dashes, underscores.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'Upper Camel-Case'</span><span class="p">)</span><span class="o">-></span><span class="na">upperCamelize</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">upperCamelize</span><span class="p">(</span><span class="s1">'Upper Camel-Case'</span><span class="p">);</span> <span class="c1">// 'UpperCamelCase'</span>
|
||||
</pre></div>
|
||||
|
||||
<h5>
|
||||
<a name="uppercasefirst" class="anchor" href="#uppercasefirst"><span class="octicon octicon-link"></span></a>upperCaseFirst</h5>
|
||||
|
||||
<p>$stringy->upperCaseFirst();</p>
|
||||
|
||||
<p>S::upperCaseFirst(string $str [, string $encoding ])</p>
|
||||
|
||||
<p>Converts the first character of the supplied string to upper case, with
|
||||
support for multibyte strings.</p>
|
||||
|
||||
<div class="highlight"><pre><span class="nx">S</span><span class="o">::</span><span class="na">create</span><span class="p">(</span><span class="s1">'σ test'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">)</span><span class="o">-></span><span class="na">upperCaseFirst</span><span class="p">();</span>
|
||||
<span class="nx">S</span><span class="o">::</span><span class="na">upperCaseFirst</span><span class="p">(</span><span class="s1">'σ test'</span><span class="p">,</span> <span class="s1">'UTF-8'</span><span class="p">);</span> <span class="c1">// 'Σ test'</span>
|
||||
</pre></div>
|
||||
|
||||
<h2>
|
||||
<a name="todo" class="anchor" href="#todo"><span class="octicon octicon-link"></span></a>TODO</h2>
|
||||
|
||||
<p><strong>count</strong> => substr_count</p>
|
||||
|
||||
<p><strong>wordCount</strong> => str_word_count</p>
|
||||
|
||||
<p><strong>wordWrap</strong></p>
|
||||
|
||||
<p><strong>excerpt</strong> ($str, $substring, $radius)</p>
|
||||
|
||||
<p><strong>pluralize</strong> ($count, $singular, $plural = null)</p>
|
||||
|
||||
<p><strong>toBoolean</strong></p>
|
||||
|
||||
<h2>
|
||||
<a name="tests" class="anchor" href="#tests"><span class="octicon octicon-link"></span></a>Tests</h2>
|
||||
|
||||
<p><a href="https://travis-ci.org/danielstjules/Stringy"><img src="https://travis-ci.org/danielstjules/Stringy.png" alt="Build Status"></a></p>
|
||||
|
||||
<p>From the project directory, tests can be ran using <code>phpunit</code></p>
|
||||
|
||||
<h2>
|
||||
<a name="license" class="anchor" href="#license"><span class="octicon octicon-link"></span></a>License</h2>
|
||||
|
||||
<p>Released under the MIT License - see <code>LICENSE.txt</code> for details.</p>
|
||||
</section>
|
||||
<footer>
|
||||
<p>This project is maintained by <a href="https://github.com/danielstjules">danielstjules</a></p>
|
||||
<p><small>Hosted on GitHub Pages — Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
|
||||
</footer>
|
||||
</div>
|
||||
<script src="javascripts/scale.fix.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
17
javascripts/scale.fix.js
Normal file
17
javascripts/scale.fix.js
Normal file
@ -0,0 +1,17 @@
|
||||
var metas = document.getElementsByTagName('meta');
|
||||
var i;
|
||||
if (navigator.userAgent.match(/iPhone/i)) {
|
||||
for (i=0; i<metas.length; i++) {
|
||||
if (metas[i].name == "viewport") {
|
||||
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
|
||||
}
|
||||
}
|
||||
document.addEventListener("gesturestart", gestureStart, false);
|
||||
}
|
||||
function gestureStart() {
|
||||
for (i=0; i<metas.length; i++) {
|
||||
if (metas[i].name == "viewport") {
|
||||
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
|
||||
}
|
||||
}
|
||||
}
|
1
params.json
Normal file
1
params.json
Normal file
File diff suppressed because one or more lines are too long
69
stylesheets/pygment_trac.css
Normal file
69
stylesheets/pygment_trac.css
Normal file
@ -0,0 +1,69 @@
|
||||
.highlight { background: #ffffff; }
|
||||
.highlight .c { color: #999988; font-style: italic } /* Comment */
|
||||
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
|
||||
.highlight .k { font-weight: bold } /* Keyword */
|
||||
.highlight .o { font-weight: bold } /* Operator */
|
||||
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
|
||||
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
|
||||
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
|
||||
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
|
||||
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
||||
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
|
||||
.highlight .ge { font-style: italic } /* Generic.Emph */
|
||||
.highlight .gr { color: #aa0000 } /* Generic.Error */
|
||||
.highlight .gh { color: #999999 } /* Generic.Heading */
|
||||
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
||||
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
|
||||
.highlight .go { color: #888888 } /* Generic.Output */
|
||||
.highlight .gp { color: #555555 } /* Generic.Prompt */
|
||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||
.highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
|
||||
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
|
||||
.highlight .kc { font-weight: bold } /* Keyword.Constant */
|
||||
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
|
||||
.highlight .kn { font-weight: bold } /* Keyword.Namespace */
|
||||
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
|
||||
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
|
||||
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
|
||||
.highlight .m { color: #009999 } /* Literal.Number */
|
||||
.highlight .s { color: #d14 } /* Literal.String */
|
||||
.highlight .na { color: #008080 } /* Name.Attribute */
|
||||
.highlight .nb { color: #0086B3 } /* Name.Builtin */
|
||||
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
|
||||
.highlight .no { color: #008080 } /* Name.Constant */
|
||||
.highlight .ni { color: #800080 } /* Name.Entity */
|
||||
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
|
||||
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
|
||||
.highlight .nn { color: #555555 } /* Name.Namespace */
|
||||
.highlight .nt { color: #000080 } /* Name.Tag */
|
||||
.highlight .nv { color: #008080 } /* Name.Variable */
|
||||
.highlight .ow { font-weight: bold } /* Operator.Word */
|
||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.highlight .mf { color: #009999 } /* Literal.Number.Float */
|
||||
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
|
||||
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
|
||||
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
|
||||
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
|
||||
.highlight .sc { color: #d14 } /* Literal.String.Char */
|
||||
.highlight .sd { color: #d14 } /* Literal.String.Doc */
|
||||
.highlight .s2 { color: #d14 } /* Literal.String.Double */
|
||||
.highlight .se { color: #d14 } /* Literal.String.Escape */
|
||||
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
|
||||
.highlight .si { color: #d14 } /* Literal.String.Interpol */
|
||||
.highlight .sx { color: #d14 } /* Literal.String.Other */
|
||||
.highlight .sr { color: #009926 } /* Literal.String.Regex */
|
||||
.highlight .s1 { color: #d14 } /* Literal.String.Single */
|
||||
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
|
||||
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
|
||||
.highlight .vc { color: #008080 } /* Name.Variable.Class */
|
||||
.highlight .vg { color: #008080 } /* Name.Variable.Global */
|
||||
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
|
||||
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
|
||||
|
||||
.type-csharp .highlight .k { color: #0000FF }
|
||||
.type-csharp .highlight .kt { color: #0000FF }
|
||||
.type-csharp .highlight .nf { color: #000000; font-weight: normal }
|
||||
.type-csharp .highlight .nc { color: #2B91AF }
|
||||
.type-csharp .highlight .nn { color: #000000 }
|
||||
.type-csharp .highlight .s { color: #A31515 }
|
||||
.type-csharp .highlight .sc { color: #A31515 }
|
255
stylesheets/styles.css
Normal file
255
stylesheets/styles.css
Normal file
@ -0,0 +1,255 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700);
|
||||
|
||||
body {
|
||||
padding:50px;
|
||||
font:14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
color:#777;
|
||||
font-weight:300;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
color:#222;
|
||||
margin:0 0 20px;
|
||||
}
|
||||
|
||||
p, ul, ol, table, pre, dl {
|
||||
margin:0 0 20px;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
line-height:1.1;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size:28px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
color:#393939;
|
||||
}
|
||||
|
||||
h3, h4, h5, h6 {
|
||||
color:#494949;
|
||||
}
|
||||
|
||||
a {
|
||||
color:#39c;
|
||||
font-weight:400;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
a small {
|
||||
font-size:11px;
|
||||
color:#777;
|
||||
margin-top:-0.6em;
|
||||
display:block;
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
width:860px;
|
||||
margin:0 auto;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left:1px solid #e5e5e5;
|
||||
margin:0;
|
||||
padding:0 0 0 20px;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family:Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal;
|
||||
color:#333;
|
||||
font-size:12px;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding:8px 15px;
|
||||
background: #f8f8f8;
|
||||
border-radius:5px;
|
||||
border:1px solid #e5e5e5;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width:100%;
|
||||
border-collapse:collapse;
|
||||
}
|
||||
|
||||
th, td {
|
||||
text-align:left;
|
||||
padding:5px 10px;
|
||||
border-bottom:1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
dt {
|
||||
color:#444;
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
th {
|
||||
color:#444;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width:100%;
|
||||
}
|
||||
|
||||
header {
|
||||
width:270px;
|
||||
float:left;
|
||||
position:fixed;
|
||||
}
|
||||
|
||||
header ul {
|
||||
list-style:none;
|
||||
height:40px;
|
||||
|
||||
padding:0;
|
||||
|
||||
background: #eee;
|
||||
background: -moz-linear-gradient(top, #f8f8f8 0%, #dddddd 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f8f8f8), color-stop(100%,#dddddd));
|
||||
background: -webkit-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
||||
background: -o-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
||||
background: -ms-linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
||||
background: linear-gradient(top, #f8f8f8 0%,#dddddd 100%);
|
||||
|
||||
border-radius:5px;
|
||||
border:1px solid #d2d2d2;
|
||||
box-shadow:inset #fff 0 1px 0, inset rgba(0,0,0,0.03) 0 -1px 0;
|
||||
width:270px;
|
||||
}
|
||||
|
||||
header li {
|
||||
width:89px;
|
||||
float:left;
|
||||
border-right:1px solid #d2d2d2;
|
||||
height:40px;
|
||||
}
|
||||
|
||||
header ul a {
|
||||
line-height:1;
|
||||
font-size:11px;
|
||||
color:#999;
|
||||
display:block;
|
||||
text-align:center;
|
||||
padding-top:6px;
|
||||
height:40px;
|
||||
}
|
||||
|
||||
strong {
|
||||
color:#222;
|
||||
font-weight:700;
|
||||
}
|
||||
|
||||
header ul li + li {
|
||||
width:88px;
|
||||
border-left:1px solid #fff;
|
||||
}
|
||||
|
||||
header ul li + li + li {
|
||||
border-right:none;
|
||||
width:89px;
|
||||
}
|
||||
|
||||
header ul a strong {
|
||||
font-size:14px;
|
||||
display:block;
|
||||
color:#222;
|
||||
}
|
||||
|
||||
section {
|
||||
width:500px;
|
||||
float:right;
|
||||
padding-bottom:50px;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size:11px;
|
||||
}
|
||||
|
||||
hr {
|
||||
border:0;
|
||||
background:#e5e5e5;
|
||||
height:1px;
|
||||
margin:0 0 20px;
|
||||
}
|
||||
|
||||
footer {
|
||||
width:270px;
|
||||
float:left;
|
||||
position:fixed;
|
||||
bottom:50px;
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 960px) {
|
||||
|
||||
div.wrapper {
|
||||
width:auto;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
header, section, footer {
|
||||
float:none;
|
||||
position:static;
|
||||
width:auto;
|
||||
}
|
||||
|
||||
header {
|
||||
padding-right:320px;
|
||||
}
|
||||
|
||||
section {
|
||||
border:1px solid #e5e5e5;
|
||||
border-width:1px 0;
|
||||
padding:20px 0;
|
||||
margin:0 0 20px;
|
||||
}
|
||||
|
||||
header a small {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
header ul {
|
||||
position:absolute;
|
||||
right:50px;
|
||||
top:52px;
|
||||
}
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 720px) {
|
||||
body {
|
||||
word-wrap:break-word;
|
||||
}
|
||||
|
||||
header {
|
||||
padding:0;
|
||||
}
|
||||
|
||||
header ul, header p.view {
|
||||
position:static;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
word-wrap:normal;
|
||||
}
|
||||
}
|
||||
|
||||
@media print, screen and (max-width: 480px) {
|
||||
body {
|
||||
padding:15px;
|
||||
}
|
||||
|
||||
header ul {
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
padding:0.4in;
|
||||
font-size:12pt;
|
||||
color:#444;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user