<commit_before><?php

namespace Apartment\Model;

use Zend\Db\TableGateway\TableGateway;

class RoomTable {
	protected $tableGateway;
	public function __construct(TableGateway $tableGateway) {
		$this->tableGateway = $tableGateway;
	}
	public function getApartmentRooms($id) {
		$id = ( int ) $id;
		
		$resultSet = $this->tableGateway->select ( array (
				'apartment_id' => $id 
		) );
		return $resultSet;
	}
	public function getRoom($id, $name) {
		
		$id = ( int ) $id;
		
		$rowSet = $this->tableGateway->select ( array (
				'apartment_id' => $id,
				'name' => $name 
		) );
		$row = $rowSet->current ();
		if (! $row) {
			
			return false;
		}
		return $row;
	}
	public function saveRoom(Room $room) {
		$data = array (
				
				'apartment_id' => ( int ) $room->apartment_id,
				'name' => $room->name,
				'power_light' => $room->power_light,
				'power_temperature' => $room->power_temperature,
				'power_device' => $room->power_device,
				'light' => $room->light,
				'temperature' => $room->temperature, 
				'temperature_outside' => $room->temperature_outside
		);
		
		if (! $this->getRoom ( ( int ) $room->apartment_id, $room->name )) {
			$this->tableGateway->insert ( $data );
		} else {
			$this->tableGateway->update ( $data, array (
					'apartment_id' => ( int ) $room->apartment_id,
					'name' => $room->name 
			) );
		}
	}
	public function deleteRoom($id, $name) {
		$id = ( int ) $id;
		if ($name != null) {
			
			return $this->tableGateway->delete ( array (
					
					'apartment_id' => $id,<commit_msg>Added the use of the prepareData() function of the room class<commit_after><?php

namespace Apartment\Model;

use Zend\Db\TableGateway\TableGateway;

class RoomTable {
	protected $tableGateway;
	public function __construct(TableGateway $tableGateway) {
		$this->tableGateway = $tableGateway;
	}
	public function getApartmentRooms($id) {
		$id = ( int ) $id;
		
		$resultSet = $this->tableGateway->select ( array (
				'apartment_id' => $id 
		) );
		
		return $resultSet;
	}
	public function getRoom($id, $name) {
		$id = ( int ) $id;
		
		$rowSet = $this->tableGateway->select ( array (
				'apartment_id' => $id,
				'name' => $name 
		) );
		$row = $rowSet->current ();
		if (! $row) {
			
			return false;
		}
		
		$row->prepareData ();
		return $row;
	}
	public function saveRoom(Room $room) {
		$data = array (
				
				'apartment_id' => ( int ) $room->apartment_id,
				'name' => $room->name,
				'power_light' => $room->power_light,
				'power_temperature' => $room->power_temperature,
				'power_device' => $room->power_device,
				'light' => $room->light,
				'temperature' => $room->temperature,
				'temperature_outside' => $room->temperature_outside 
		);
		
		if (! $this->getRoom ( ( int ) $room->apartment_id, $room->name )) {
			$this->tableGateway->insert ( $data );
		} else {
			$this->tableGateway->update ( $data, array (
					'apartment_id' => ( int ) $room->apartment_id,
					'name' => $room->name 
			) );
		}
	}
	public function deleteRoom($id, $name) {
		$id = ( int ) $id;
		if ($name != null) {
			
			return $this->tableGateway->delete ( array (
					
					'apartment_id' => $id,
{'fraction_non_alphanumeric': 0.17615262321144673, 'fraction_numerical': 0.0, 'mean_word_length': 3.1779548472775563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4326704', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1119, 'n_words': 218}