Esempio n. 1
0
 /**
  * Virtual properties like "length".
  *
  * @param string $property
  *
  * @return mixed
  */
 public function __get($property)
 {
     if ($property == 'length') {
         return mb_strlen($this->text, 'UTF-8');
     }
     $properties = \Sledgehammer\reflect_properties($this);
     $properties['public']['length'] = -1;
     \Sledgehammer\warning('Property: "' . $property . '" doesn\'t exist in a "' . get_class($this) . '" object.', \Sledgehammer\build_properties_hint($properties));
 }
Esempio n. 2
0
 /**
  * Get a property or fields value.
  *
  * @param string $property
  *
  * @return mixed
  */
 public function __get($property)
 {
     if (property_exists($this->instance, $property)) {
         if (array_key_exists($property, $this->fields)) {
             notice('Property "' . $property . '" is ambiguous. It\'s available in both the instance as the junction fields.', "To modify the mapping of the junction field change the value of \$ModelConfig->hasMany[\$relation]['fields']['" . $property . "']");
         }
         return $this->instance->{$property};
     }
     if (array_key_exists($property, $this->fields)) {
         return $this->fields[$property];
     }
     if ($this->dynamicFields) {
         $this->fields[$property] = null;
         return;
     }
     $properties = \Sledgehammer\reflect_properties($this->instance);
     $properties['public'] = array_merge($properties['public'], $this->fields);
     warning('Property "' . $property . '" doesn\'t exist in a ' . get_class($this) . ' (' . get_class($this->instance) . ') object', \Sledgehammer\build_properties_hint($properties));
 }
Esempio n. 3
0
 /**
  * Report that $property doesn't exist and set the property to the given $value.
  *
  * @param string $property
  * @param mixed  $value
  */
 public function __set($property, $value)
 {
     \Sledgehammer\warning('Property "' . $property . '" doesn\'t exist in a ' . get_class($this) . ' object', \Sledgehammer\build_properties_hint(\Sledgehammer\reflect_properties($this)));
     $this->{$property} = $value;
     // Add the property to the object. (PHP's default behavior)
 }
Esempio n. 4
0
 /**
  * Access CURLINFO_* info as properties.
  *
  * @param string $property
  *
  * @return mixed
  */
 public function __get($property)
 {
     $const = 'CURLINFO_' . strtoupper($property);
     if (defined($const)) {
         $option = eval('return ' . $const . ';');
         $this->waitForCompletion();
         return curl_getinfo($this->handle, $option);
     }
     $properties = \Sledgehammer\reflect_properties($this);
     $properties['public'] = array_merge($properties['public'], curl_getinfo($this->handle));
     \Sledgehammer\warning('Property "' . $property . '" doesn\'t exist in a ' . get_class($this) . ' object', \Sledgehammer\build_properties_hint($properties));
 }