Author: grobmeier
Date: Fri May 22 14:02:10 2009
New Revision: 777528

URL: http://svn.apache.org/viewvc?rev=777528&view=rev
Log:
added reflection utils class

Added:
    incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php
    incubator/log4php/trunk/src/test/php/LoggerReflectionUtilsTest.php
Modified:
    incubator/log4php/trunk/src/main/php/LoggerManager.php

Modified: incubator/log4php/trunk/src/main/php/LoggerManager.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerManager.php?rev=777528&r1=777527&r2=777528&view=diff
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerManager.php (original)
+++ incubator/log4php/trunk/src/main/php/LoggerManager.php Fri May 22 14:02:10 
2009
@@ -53,6 +53,7 @@
                'LoggerLevel' => '/LoggerLevel.php',
                'LoggerMDC' => '/LoggerMDC.php',
                'LoggerNDC' => '/LoggerNDC.php',
+               'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
                'LoggerConfigurator' => '/LoggerConfigurator.php',
                'LoggerConfiguratorBasic' => 
'/configurators/LoggerConfiguratorBasic.php',
                'LoggerConfiguratorIni' => 
'/configurators/LoggerConfiguratorIni.php',

Added: incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php?rev=777528&view=auto
==============================================================================
--- incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php (added)
+++ incubator/log4php/trunk/src/main/php/LoggerReflectionUtils.php Fri May 22 
14:02:10 2009
@@ -0,0 +1,41 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *
+ * @package log4php
+ */
+ 
+ /**
+  * Provides methods for reflective use on php objects
+  */
+class LoggerReflectionUtils {
+       /**
+        * Creates an instances from the given class name.
+        *
+        * @param string $classname
+        * @return an object from the class with the given classname
+        */
+       public static function createObject($class) {
+               if(!empty($class)) {
+                       $class = basename($class);
+                       return new $class();
+               }
+               return null;
+       }
+}
+ 
+ ?>
\ No newline at end of file

Added: incubator/log4php/trunk/src/test/php/LoggerReflectionUtilsTest.php
URL: 
http://svn.apache.org/viewvc/incubator/log4php/trunk/src/test/php/LoggerReflectionUtilsTest.php?rev=777528&view=auto
==============================================================================
--- incubator/log4php/trunk/src/test/php/LoggerReflectionUtilsTest.php (added)
+++ incubator/log4php/trunk/src/test/php/LoggerReflectionUtilsTest.php Fri May 
22 14:02:10 2009
@@ -0,0 +1,35 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @category   tests   
+ * @package    log4php
+ * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License, 
Version 2.0
+ * @version    SVN: $Id$
+ * @link       http://logging.apache.org/log4php
+ */
+
+/**
+ * Tests the LoggerReflectionUtils class
+ */
+class LoggerReflectionUtilsTest extends PHPUnit_Framework_TestCase {
+
+       public function testCreateObject() {
+               $object = 
LoggerReflectionUtils::createObject('LoggerLayoutSimple');
+               $name = get_class($object);
+               self::assertEquals($name, 'LoggerLayoutSimple');
+       }
+}


Reply via email to