Exemplo n.º 1
0
 /**
  * @covers Puml\Model\Object::hasMethod
  */
 public function testHasMethod()
 {
     $method = $this->getMock('\\Puml\\Model\\Method');
     $this->assertFalse($this->object->hasMethod($method));
     $this->object->addMethod($method);
     $this->assertTrue($this->object->hasMethod($method));
 }
Exemplo n.º 2
0
 /**
  * Extract the methods of the reflection class into the object
  *
  * @param \ReflectionClass   $reflectedObject The reflected object to
  *                                            extract the methods out of.
  * @param \Puml\Model\Object $object          The object to add the methods
  *                                            to.
  *
  * @return void
  * @since 0.1
  */
 protected function extractMethods(\ReflectionClass $reflectedObject, \Puml\Model\Object $object)
 {
     foreach ($reflectedObject->getMethods() as $reflectedMethod) {
         $reflectedMethod->setAccessible(true);
         $method = new Method();
         /* Skip when its not declared in this class */
         if ($reflectedMethod->getDeclaringClass()->getName() != $reflectedObject->getName()) {
             continue;
         }
         if ($reflectedMethod->isStatic()) {
             $method->setVisibility(\ReflectionProperty::IS_STATIC);
         } elseif ($reflectedMethod->isPublic()) {
             $method->setVisibility(\ReflectionProperty::IS_PUBLIC);
         } elseif ($reflectedMethod->isProtected()) {
             $method->setVisibility(\ReflectionProperty::IS_PROTECTED);
         } else {
             $method->setVisibility(\ReflectionProperty::IS_PRIVATE);
         }
         /* Determine type */
         $type = $this->determineMethodType($reflectedMethod);
         $method->setName($reflectedMethod->getName())->setType($type);
         $this->extractParameters($reflectedMethod, $method);
         $object->addMethod($method);
     }
 }