Example #1
0
 /**
  * Gets an attribute value.
  *
  * @param   string  $key    The attribute key (field) name.
  * @return  mixed
  */
 protected function getAttribute($key)
 {
     if (true === $this->isCalculatedAttribute($key)) {
         return $this->getCalculatedAttribute($key);
     }
     $this->touch();
     return $this->attributes->get($key);
 }
Example #2
0
 /**
  * Registers a new value for a given attribute.
  * If the attribute hasn't changed yet, the new value is stored
  * as the original value of the attribute. If the attribute already has
  * an original value stored, and the new value equals to it, the attribute
  * change is unregistered. Otherwise, the new value is ignored; the
  * original value is kept.
  *
  * @return void
  */
 public function registerAttributeChange($attrName, $newValue)
 {
     if (!$this->attributeChanged($attrName)) {
         $oldValue = $this->attributes->get($attrName);
         if ((string) $newValue != (string) $oldValue) {
             $this->changedAttributes[$attrName] = $oldValue;
         }
     } elseif ((string) $newValue == (string) $this->changedAttributes[$attrName]) {
         unset($this->changedAttributes[$attrName]);
     }
 }
Example #3
0
 public function testSeRetornaVariosAtributosHtmlComBaseEmUmArray()
 {
     $attribute = new Attributes();
     $attribute->setMany(['href' => 'http://www.webdevbr.com.br', 'class' => 'btn btn-success']);
     $this->assertEquals('href="http://www.webdevbr.com.br" class="btn btn-success"', $attribute->get());
 }