package cn.edu.seu.ise.dca.app.php.model;

import java.util.ArrayList;
import java.util.List;

public class PHPClass {
	private String name;
	private String fullName;
	private long revision;
	private long startLine;
	private long endLine;	
	private List<PHPFunction> functions;
	
	public PHPClass(long revision) {
		this.revision = revision;
		functions = new ArrayList<PHPFunction>();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public long getRevision() {
		return revision;
	}

	public void setRevision(long revision) {
		this.revision = revision;
	}

	public long getStartLine() {
		return startLine;
	}

	public void setStartLine(long startLine) {
		this.startLine = startLine;
	}

	public long getEndLine() {
		return endLine;
	}

	public void setEndLine(long endLine) {
		this.endLine = endLine;
	}

	public List<PHPFunction> getFunctions() {
		return functions;
	}

	public void addFunction(PHPFunction phpfunction) {
		this.functions.add(phpfunction);
	}
	
	/**
	 * Get the total line number of the class
	 * @return
	 */
	public long sizeOfLines() {
		return this.endLine - this.startLine + 1;
	}
	
	/**
	 * Get the number of functions defined in class
	 * @return
	 */
	public int sizeOfFunctions() {
		return functions.size();
	}

	@Override
	public String toString() {
		StringBuffer buffer = new StringBuffer();
		buffer.append("[revision:").append(this.getRevision()).append(", class name:").append(this.getFullName())
			.append(", lines:").append(this.sizeOfLines()).append(", start line:").append(this.getStartLine())
			.append(", end line:").append(this.getEndLine()).append(", functions:").append(this.sizeOfFunctions()).append("]");
		return buffer.toString();
	}
}
