/** * Convert data array into entity * * @return AccountGroup * @param array $data * @access public */ public function build($data) { $group = new AccountGroup(); $group->setGroupName($data['group_name']); $group->setGroupDescription($data['group_description']); $group->setDateAdded($data['group_date_added']); $group->setDateRemoved($data['group_date_removed']); $group->setGroupID($data['group_id']); # parent group is not included, but mapped via the marshaler return $group; }
/** * Return the parent account node tree * * @access public * @return AccountGroupNode * */ public function end() { $closed = new DateTime(); $closed->setDate(3000, 1, 1); $closed->setTime(0, 0, 0); # create root AccountGroup $rootGroup = new AccountGroup(); $rootGroup->setGroupName('Root Group'); $rootGroup->setGroupDescription('Top level group'); $rootGroup->setDateAdded($this->now); $rootGroup->setDateRemoved($closed); # add the group to the node $this->rootNode->setInternal($rootGroup); return $this->rootNode; }
/** * Return empty node * * @access public * @return void * */ public function getNode() { if ($this->groupTreeNode === null) { $this->groupTreeNode = new AccountGroupNode(array('id' => uniqid())); $closed = new DateTime(); $closed->setDate(3000, 1, 1); $closed->setTime(0, 0, 0); $rootGroup = new AccountGroup(); $rootGroup->setGroupName('Debit'); $rootGroup->setGroupDescription('Debit Group'); $rootGroup->setDateAdded($this->now); $rootGroup->setDateRemoved($closed); $this->groupTreeNode->setInternal($rootGroup); } return $this->groupTreeNode; }
/** * @expectedException IComeFromTheNet\Ledger\Exception\LedgerException * @expectedExceptionMessage Group Name must be a string < 150 characters * */ public function testErrorAccountGroupNameExceedsLimit() { $groupName = str_repeat('a', 151); $group = new AccountGroup(); $group->setGroupName($groupName); }
/** * Return the parent NodeBuilder * * @access public * @return NodeBuilderInterface * */ public function end() { $group = new AccountGroup(); $closed = new DateTime(); $closed->setDate(3000, 1, 1); $closed->setTime(0, 0, 0); $group->setGroupName($this->groupName); $group->setGroupDescription($this->groupDescription); $group->setDateAdded($this->now); $group->setDateRemoved($closed); # attach the new accountGroup entity to the tree node $this->getNode()->setInternal($group); # add new tree node to the parent node $this->parentNode->getNode()->addChild($this->getNode()); return $this->parentNode; }