public function completeEntity() { $missingMethod = $this->analyzer->listMissingMethod(); $lines = file($this->analyzer->getReflection()->getFileName()); $lineToSet = $lines[$this->analyzer->getReflection()->getEndLine() - 1]; $endClassPos = strrpos($lineToSet, '}'); $before = substr($lineToSet, 0, $endClassPos - 2); $after = substr($lineToSet, $endClassPos - 2); foreach ($missingMethod as $data) { switch ($data['type']) { case EntityAnalyzer::GETTER: $before .= $this->createGetter($data['column']); break; case EntityAnalyzer::SETTER: $before .= $this->createSetter($data['column']); break; case EntityAnalyzer::ADDER: $before .= $this->createAdder($data['column']); break; case EntityAnalyzer::REMOVER: $before .= $this->createRemover($data['column']); break; } } $lines[$this->analyzer->getReflection()->getEndLine() - 1] = $before . $after; file_put_contents($this->analyzer->getReflection()->getFileName(), implode('', $lines)); }
public function completeEntity() { $missingMethod = $this->analyzer->listMissingMethod(); $lines = file($this->analyzer->getReflection()->getFileName()); $lineToSet = $lines[$this->analyzer->getReflection()->getEndLine() - 1]; $endClassPos = strrpos($lineToSet, '}'); $before = substr($lineToSet, 0, $endClassPos - 2); $after = substr($lineToSet, $endClassPos - 2); foreach ($missingMethod as $method) { $before .= $this->getBuilder($method)->getMethodSrc(); } $lines[$this->analyzer->getReflection()->getEndLine() - 1] = $before . $after; file_put_contents($this->analyzer->getReflection()->getFileName(), implode('', $lines)); }
public function testListMissingMethod() { $this->assertEquals($this->entityAnalyzer->listMissingMethod(), array('getUid' => array('type' => EntityAnalyzer::GETTER, 'column' => 'uid'), 'setUid' => array('type' => EntityAnalyzer::SETTER, 'column' => 'uid'), 'getCn' => array('type' => EntityAnalyzer::GETTER, 'column' => 'cn'), 'setCn' => array('type' => EntityAnalyzer::SETTER, 'column' => 'cn'), 'getSn' => array('type' => EntityAnalyzer::GETTER, 'column' => 'sn'), 'setSn' => array('type' => EntityAnalyzer::SETTER, 'column' => 'sn'), 'getGivenName' => array('type' => EntityAnalyzer::GETTER, 'column' => 'givenName'), 'setGivenName' => array('type' => EntityAnalyzer::SETTER, 'column' => 'givenName'), 'getMail' => array('type' => EntityAnalyzer::GETTER, 'column' => 'mail'), 'setMail' => array('type' => EntityAnalyzer::SETTER, 'column' => 'mail'), 'getTelephoneNumber' => array('type' => EntityAnalyzer::GETTER, 'column' => 'telephoneNumber'), 'addTelephoneNumber' => array('type' => EntityAnalyzer::ADDER, 'column' => 'telephoneNumber'), 'removeTelephoneNumber' => array('type' => EntityAnalyzer::REMOVER, 'column' => 'telephoneNumber'))); }
public function testListMissingMethod() { $this->assertEquals($this->entityAnalyzer->listMissingMethod(), array('getCn' => array('type' => EntityAnalyzer::GETTER, 'column' => 'cn'), 'setCn' => array('type' => EntityAnalyzer::SETTER, 'column' => 'cn'), 'getMember' => array('type' => EntityAnalyzer::GETTER, 'column' => 'member'), 'addMember' => array('type' => EntityAnalyzer::ADDER, 'column' => 'member'), 'removeMember' => array('type' => EntityAnalyzer::REMOVER, 'column' => 'member'))); }