src/Server.php
public function expose($other, $prefix = '')
    {
        if (!is_string($other) && !is_object($other)) {
            throw new \InvalidArgumentException('Invalid adoption');
        }

        if (!is_string($prefix)) {
            throw new \InvalidArgumentException('Invalid prefix');
        }

        $prefix = rtrim($prefix, '.');
        if ($prefix !== '') {
            $prefix .= '.';
        }

        if (is_object($other)) {
            // An object was passed.
            $class = get_class($other);
            foreach (get_class_methods($class) as $method) {
                // Only adopt public methods of the object,
                // excluding the constructor and static methods.
                // To also register static methods, call this method
                // a second time with get_class($other).
                $reflector = new \ReflectionMethod($class, $method);
                if ($reflector->isPublic() && !$reflector->isConstructor() &&
                    !$reflector->isStatic()) {
                    $this[$prefix . $method] = array($other, $method);
                }
            }
        } else {
            // A class was passed.
            foreach (get_class_methods($other) as $method) {
                // Only adopt methods which are both public and static.
                $reflector = new \ReflectionMethod($other, $method);
                if ($reflector->isPublic() && $reflector->isStatic()) {
                    $this[$prefix . $method] = array($other, $method);
                }
            }
        }
    }
public function expose($other, $prefix = '')
    {
        if (!is_string($other) && !is_object($other)) {
            throw new \InvalidArgumentException('Invalid adoption');
        }

        if (!is_string($prefix)) {
            throw new \InvalidArgumentException('Invalid prefix');
        }

        $prefix = rtrim($prefix, '.');
        if ($prefix !== '') {
            $prefix .= '.';
        }

        if (is_object($other)) {
            // An object was passed.
            $class = get_class($other);
            foreach (get_class_methods($class) as $method) {
                // Only adopt public methods of the object,
                // excluding the constructor and static methods.
                // To also register static methods, call this method
                // a second time with get_class($other).
                $reflector = new \ReflectionMethod($class, $method);
                if ($reflector->isPublic() && !$reflector->isConstructor() &&
                    !$reflector->isStatic()) {
                    $this[$prefix . $method] = array($other, $method);
                }
            }
        } else {
            // A class was passed.
            foreach (get_class_methods($other) as $method) {
                // Only adopt methods which are both public and static.
                $reflector = new \ReflectionMethod($other, $method);
                if ($reflector->isPublic() && $reflector->isStatic()) {
                    $this[$prefix . $method] = array($other, $method);
                }
            }
        }
    }
Expose the public methods of a class or object,
with an optional prefix.

\param mixed $other
Class or object to expose.
For classes, only public static methods are exposed.
For objects, public non-static methods are exposed,
except for the constructor.

\param string $prefix
Prefix under which the class/object's methods
will be exposed. Defaults to the empty string
(ie. the methods are exposed without any prefix).

\return
This method does not return any value.

\note
To expose all public methods of an object (both
static and non-static), call this method twice:
- once with the actual object
- and a second time with <code>get_class($object)</code>