Implementation.php #1

  • //
  • guest/
  • perforce_software/
  • chronicle/
  • main/
  • tests/
  • phpunit/
  • P4/
  • Model/
  • Implementation.php
  • View
  • Commits
  • Open Download .zip Download (1 KB)
<?php
/**
 * An implementation of the model abstract class for testing.
 *
 * @copyright   2011 Perforce Software. All rights reserved.
 * @license     Please see LICENSE.txt in top-level folder of this distribution.
 * @version     <release>/<patch>
 */
class P4_Model_Implementation extends P4_ModelAbstract
{
    protected   $_fields    = array('foo' => null, 'bar' => null, 'baz' => null);

    /**
     * Get model fields.
     *
     * @return  array   list of field names.
     */
    public function getFields()
    {
        return array_keys($this->_fields);
    }

    /**
     * Get model field value.
     *
     * @param   string  $field  name of field to get value of.
     * @return  mixed   value of field.
     */
    public function getValue($field)
    {
        return isset($this->_fields[$field]) ? $this->_fields[$field] : null;
    }

    /**
     * Check if model has field.
     *
     * @param   string  $field  name of field to check for.
     * @return  bool    true if model has field; false otherwise.
     */
    public function hasField($field)
    {
        return array_key_exists($field, $this->_fields);
    }

    /**
     * Set model values.
     *
     * @param   array   $values     values to set on model.
     */
    public function setValues($values)
    {
        $this->_fields = $values;
    }
}
# Change User Description Committed
#1 16170 perforce_software Move Chronicle files to follow new path scheme for branching.
//guest/perforce_software/chronicle/tests/phpunit/P4/Model/Implementation.php
#1 8972 Matt Attaway Initial add of the Chronicle source code