<commit_before><?php

class App_Model_Allocation extends Standard_Model
{
	protected $_dbTable = "App_Model_DbTable_Allocations";
	
	protected $_columns = array(
		'income_id' => 'int',
		'expense_id' => 'int',
		'amount' => 'float',
		);

	public function save()
	{
		$table = $this->getDbTable();
		$data = $this->_data;
		$id = $table->insert($data);
		$expense = $this->getExpense();
		$income = $this->getIncome();
		$expense->updateTotals($income->date);
		return $this;
	}
	
	public function total($end, $start = null, $expenses = null)
	{
		$user = Zend_Auth::getInstance()->getIdentity();
		$table = $this->getDbTable();
		$expense_id = null;
		if(!empty($expenses))
		{
			if(is_array($expenses))
			{
				$expense_id = array();
				foreach($expenses as $expense)
				{
					$expense_id[] = $expense->id;
				}
			}
			else
			{
				$expense_id = $expenses->id;
			}
		}
		
		return $table->total($user->id, $end, $start, $expense_id);
	}
	
	public function totalByIncome(App_Model_Income $income)<commit_msg>allow an array of ids and not just an array of objects<commit_after><?php

class App_Model_Allocation extends Standard_Model
{
	protected $_dbTable = "App_Model_DbTable_Allocations";
	
	protected $_columns = array(
		'income_id' => 'int',
		'expense_id' => 'int',
		'amount' => 'float',
		);

	public function save()
	{
		$table = $this->getDbTable();
		$data = $this->_data;
		$id = $table->insert($data);
		$expense = $this->getExpense();
		$income = $this->getIncome();
		$expense->updateTotals($income->date);
		return $this;
	}
	
	public function total($end, $start = null, $expenses = null)
	{
		$user = Zend_Auth::getInstance()->getIdentity();
		$table = $this->getDbTable();
		$expense_id = null;
		if(!empty($expenses))
		{
			if(is_array($expenses))
			{
				$expense_id = array();
				foreach($expenses as $expense)
				{
					if($expense instanceof App_Model_Expense)
						$expense_id[] = $expense->id;
					else
						$expense_id[] = $expense;
				}
			}
			elseif($expenses instanceof App_Model_Expense)
			{
				$expense_id = $expenses->id;
			}
			else
			{
				$expense_id = $expenses;
			}
		}
		
		return $table->total($user->id, $end, $start, $expense_id);
	}
	
	public function totalByIncome(App_Model_Income $income)
{'fraction_non_alphanumeric': 0.17094774136403898, 'fraction_numerical': 0.0, 'mean_word_length': 3.7358490566037736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '7536552', 'n_tokens_mistral': 979, 'n_tokens_neox': 827, 'n_words': 155}