brainsware / sauce
Sauce is a general purpose library providing containers and functions that ease development in PHP.
Installs: 512
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/brainsware/sauce
Requires
- php: >= 5.4.0
Requires (Dev)
- brainsware/grease: @dev
This package is not auto-updated.
Last update: 2025-10-25 20:41:50 UTC
README
Sauce is a general purpose library providing containers and functions that ease development in PHP.
Currently Sauce is written and tested for PHP 5.4.x.
Provided classes/traits:
Sauce\SObject- A simple key-value storeSauce\Vector- A classic array with ordered integer keysSauce\String- A simple string representation with utility methodsSauce\Immutable- An abstract class implementingArrayAccessbut denying access to any set methodsSauce\ImmutableObject- A version ofObjectimplemeningImmutableSauce\CallableProperty- A trait implementing__callwhich allows calling a property holding a function - if callableSauce\AwareObject- A version ofObjectstoring all keys that have been changedSauce\Path- A simple path representation with utility methodsSauce\DateTime- A class extending the originalDateTimeclass with sane default formatsSauce\CliColors- A class for making colored CLI output.
Provided global functions:
dump()- Replacement forvar_dump()that can take arbitrary data; when not on the command line, this function will wrap the result in a<pre>tag.sdump()- Replacement forvar_export($value, true)V()- Create a newVectorfrom given dataA()- Create a newObjectfrom given dataAr()- Recursively createObjectinstances from given data (arrays in arrays will be also instantiated asObject)S()- Create aStringinstance from given stringVs()- Creates aVectorinstance with given strings, pushing each argument asStringinstance onto the Vector.ensure()- Define a function/method contract, throws an InvalidArgumentException when contract is not fulfilled. See comments on that function for documentation.is_not_null()- Check whether given data is not nullis_an_array()- Check whether given data is an array or an instance of any class extendingObjector implementingArrayAccessis_a_string()- Check whether given data is a string or an instance ofStringis_cli()- Check whether the current environment is the command line interface or CGI/mod_phpis_cli_server()- Check whether the application server running PHP is the built-in server.split_uri()- Split a string by/and remove empty leading/trailing stringspath_info()- Gather PHP'sPATH_INFOor build it fromSCRIPT_NAMEandREQUEST_URI, removesGETparameters if present.http_method()- Returns method reported by the server (REQUEST_METHOD), but overrides it if a_methodparameters was sent with the request. (Useful for resource/CRUD controllers)or_equals()- Check whether given variable is set and not null, basically mimicking Ruby's or-equals operator (||=)has_method($object, $method)- Check whether or not given object or class has a given method defined.