phpDocumentor\Descriptor\TraitDescriptor::getMagicMethods PHP Method

getMagicMethods() public method

public getMagicMethods ( ) : phpDocumentor\Descriptor\Collection
return phpDocumentor\Descriptor\Collection
    public function getMagicMethods()
    {
        /** @var Collection $methodTags */
        $methodTags = clone $this->getTags()->get('method', new Collection());
        $methods = new Collection();
        /** @var Tag\MethodDescriptor $methodTag */
        foreach ($methodTags as $methodTag) {
            $method = new MethodDescriptor();
            $method->setName($methodTag->getMethodName());
            $method->setDescription($methodTag->getDescription());
            $method->setParent($this);
            $methods->add($method);
        }
        return $methods;
    }

Usage Example

 /**
  * @covers phpDocumentor\Descriptor\TraitDescriptor::getMagicMethods
  */
 public function testMagicMethodsReturnsExpectedCollectionWithTags()
 {
     $mockMethodDescriptor = m::mock('phpDocumentor\\Descriptor\\Tag\\MethodDescriptor');
     $mockMethodDescriptor->shouldReceive('getMethodName')->andReturn('Sample');
     $mockMethodDescriptor->shouldReceive('getDescription')->andReturn('Sample description');
     $methodCollection = new Collection(array($mockMethodDescriptor));
     $this->fixture->getTags()->set('method', $methodCollection);
     $magicMethodsCollection = $this->fixture->getMagicMethods();
     $this->assertInstanceOf('phpDocumentor\\Descriptor\\Collection', $magicMethodsCollection);
     $this->assertSame(1, $magicMethodsCollection->count());
     $this->assertSame('Sample', $magicMethodsCollection[0]->getName());
     $this->assertSame('Sample description', $magicMethodsCollection[0]->getDescription());
     $this->assertSame($this->fixture, $magicMethodsCollection[0]->getParent());
 }