FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
Reflectory.php
1 <?php
2 /*
3 Copyright (C) 2015, Siemens AG
4 Author: Steffen Weber
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 version 2 as published by the Free Software Foundation.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 namespace Fossology\Lib\Test;
21 
22 use ReflectionClass;
25 
26 // setup autoloading
27 require_once(dirname(dirname(dirname(__DIR__))) . "/vendor/autoload.php");
28 
29 
31 {
32  public static function invokeObjectsMethodnameWith($object, $fun, array $args=array())
33  {
34  $reflection = new ReflectionClass($object);
36  $method = $reflection->getMethod($fun);
37  $method->setAccessible(true);
38  return $method->invokeArgs($object,$args);
39  }
40 
41  public static function getObjectsProperty($object, $prop)
42  {
43  $reflection = new ReflectionClass($object);
45  $property = $reflection->getProperty($prop);
46  $property->setAccessible(true);
47  return $property->getValue($object);
48  }
49 
50  public static function setObjectsProperty($object, $prop, $value)
51  {
52  $reflection = new ReflectionClass($object);
54  $property = $reflection->getProperty($prop);
55  $property->setAccessible(true);
56  $property->setValue($object, $value);
57  }
58 }