It is a bit mean to put such a headline on top, but thats the current status we have to deal with at our company. I also don't want to bash somebody, Log4Php is doing its job in a great way. But since i developed a proxy logger component, i want to use it. The proxy logger component can work with psr logger interface, so i need to create a adapter to get it used ;-).
The usage is simple, depending on the way you either choose the adapter "Log4PhpToPsrLoggerAdapter" or "PsrToLog4PhpAdapter". The only drawback, you are loosing the "trace" log level of log4php and all the fancy stuff of a log4php logger. This component is simple and has just a few lines of code (you are welcome to join), so the main focus is to support the log level methods like "$logger->warn()" and not more.
By using this component, you are able to use type hints also for basic data types.
This component includes class definitions for php basic data types like:
Boolean
Floating point
Integer
String
Numeric
Features
Enables type hints for basic php types
Types shipped with useful methods
Are comparable with native php types by using "=="
Provides generic type casting by implemented "toString()" methods (and so on)
Usage
Example
/**
* Class with type hint for string
*
* @author stev leibelt
* @since 2013-08-04
*/
class MyClass
{
/**
* @var array
* @author stev leibelt
* @since 2013-08-04
*/
private $strings = array();
/**
* Super cool method with type hint for string
*
* @author stev leibelt
* @since 2013-08-04
*/
public function addString(\Net\Bazzline\Component\DataType\String $string)
{
$this->strings[] = $string;
return $this;
}
}
$myString = new \Net\Bazzline\Component\DataType\String('super cool test string');
$myClass = new MyClass();
$myClass->addString($myString);
Hints
Extend provided types with classes in own namespace.
If you add a super cool method to your type, push it and be a part of the development team
I started developing this component because of the many casts i have to do while dealing with php's basic data types.
As general, i searched the web for existing and easy to use components but could not find them. If you find one, please tell me.
Last but not least SplTypes are still experimental.