Author - Gopi Chand Post Views - 57 views
Pattern

Transform View Pattern

The Transform View pattern includes a display mechanism that processes one element at a time and transforms it into an end-user representation such as HTML.

For example

<?php
class StudentInformation
{
private $_student_name;
private $_student_city = '';
public function __construct($student_name)
{
$this->_student_name = $student_name;
}
public function getStudentName()
{
return $this->_student_name;
}
public function setStudentCity($student_city)
{
$this->_student_city = $student_city;
}
public function getStudentCity()
{
return $this->_student_city;
}
}
class Transform_View
{
public function Student_Information_display($entity)
{
$result = "<table>\n";
$rc = new ReflectionClass(get_class($entity));
foreach ($rc->getMethods() as $method) {
$methodName = $method->getName();
if (strstr($methodName, 'get') == $methodName) {
$field = str_replace('get', '', $methodName);
$result .= "<tr>\n";
$result .= "<td>{$field}</td>\n";
$result .= "<td>" . $entity->$methodName() . "</td>\n";
$result .= "</tr>\n";
}
}
$result .= "</table>\n";
return $result;
}
}
$StudentInformation = new StudentInformation('Gopi');
$StudentInformation->setStudentCity('Mohali');
$viewInfor = new Transform_View();
echo $viewInfor->Student_Information_display($StudentInformation);

Output

Output

StudySection provides a big list of certification exams through its online platform. The French Certification Exam can help you to certify your skills to communicate in the French language. Whether you are new to the language or you are an expert in it, this French certification exam can test the ability of anybody’s command over the French language.

Leave a Reply

Your email address will not be published. Required fields are marked *

fiteesports.com rivierarw.com cratosroyalbet betwoon grandpashabet grandpashabet giriş deneme bonusu veren siteler casino siteleri