Exemplo n.º 1
0
 public function __get($field)
 {
     $this->_operations[] = function ($input) use($field) {
         return Objects::getValue($input, $field);
     };
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @test
  * @dataProvider toBoolean
  * @param $string
  * @param $expected
  */
 public function shouldConvertToBoolean($string, $expected)
 {
     //when
     $toBoolean = Booleans::toBoolean($string);
     //then
     $this->assertEquals($expected, $toBoolean, 'To convert: ' . Objects::toString($string) . ' Expected: ' . Objects::toString($expected));
 }
Exemplo n.º 3
0
 public function _addBindValue($value)
 {
     if (is_array($value)) {
         $this->_addBindArrayValue($value);
     } else {
         $this->_boundValues[] = is_bool($value) ? Objects::booleanToString($value) : $value;
     }
 }
Exemplo n.º 4
0
 private function convertRowToModel($row, $aliasToOffset, $joinsToStore)
 {
     $model = $this->extractModelFromResult($this->metaInstance, $row, $aliasToOffset[$this->alias]);
     foreach ($joinsToStore as $joinedModel) {
         if ($joinedModel->storeField()) {
             $instance = $this->extractModelFromResult($joinedModel->getModelObject(), $row, $aliasToOffset[$joinedModel->alias()]);
             Objects::setValueRecursively($model, $joinedModel->destinationField(), $instance);
         }
     }
     return $model;
 }
Exemplo n.º 5
0
 private static function stringifyArrayElements($array)
 {
     $elements = array();
     $isAssociative = array_keys($array) !== range(0, sizeof($array) - 1);
     array_walk($array, function ($element, $key) use(&$elements, $isAssociative) {
         if ($isAssociative) {
             $elements[] = "<{$key}> => " . Objects::toString($element);
         } else {
             $elements[] = Objects::toString($element);
         }
     });
     return $elements;
 }
Exemplo n.º 6
0
 private function substituteParam()
 {
     $value = $this->_boundValues[$this->_param_index];
     $this->_param_index++;
     if ($value === null) {
         return "null";
     }
     if (is_bool($value)) {
         return Objects::booleanToString($value);
     }
     $value = Db::getInstance()->_dbHandle->quote($value);
     return $value;
 }
Exemplo n.º 7
0
 public function render(OuzoExceptionData $exceptionData, $viewName)
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     $errorMessage = $exceptionData->getMessage();
     $errorTrace = $exceptionData->getStackTrace();
     Logger::getLogger(__CLASS__)->error($exceptionData->getOriginalMessage());
     Logger::getLogger(__CLASS__)->error(Objects::toString($errorTrace));
     $this->clearOutputBuffers();
     header($exceptionData->getHeader());
     $responseType = ResponseTypeResolve::resolve();
     header('Content-type: ' . $responseType);
     $additionalHeaders = $exceptionData->getAdditionalHeaders();
     array_walk($additionalHeaders, function ($header) {
         header($header);
     });
     /** @noinspection PhpIncludeInspection */
     require ViewPathResolver::resolveViewPath($viewName, $responseType);
 }
Exemplo n.º 8
0
 public function revertProperty($keys)
 {
     $keys = Arrays::toArray($keys);
     $config =& $this->_config;
     $overriddenConfig =& $this->_overriddenConfig;
     $overriddenKey = null;
     foreach ($keys as $key) {
         if (!array_key_exists($key, $overriddenConfig)) {
             throw new InvalidArgumentException('Cannot revert. No configuration override for: ' . Objects::toString($keys));
         }
         $config =& $config[$key];
         if (is_array($overriddenConfig[$key])) {
             $overriddenConfig =& $overriddenConfig[$key];
         } else {
             $overriddenKey = $key;
         }
     }
     $config = $overriddenConfig[$overriddenKey];
 }
Exemplo n.º 9
0
 public function containsKeyAndValue($elements)
 {
     $contains = array_intersect_key($this->actual, $elements);
     $elementsString = Objects::toString($elements);
     AssertAdapter::assertEquals($elements, $contains, "Cannot find key value pairs {$elementsString} in actual {$this->actualString}");
     return $this;
 }
Exemplo n.º 10
0
 /**
  * @test
  */
 public function shouldReturnValueFormMultidimensionalArray()
 {
     //given
     $array = array('id' => 123, 'name' => 'John', 'info' => array('account' => array('number' => '2343-de', 'info' => 'some info about account')));
     //when
     $value = Objects::getValueRecursively($array, 'info->account->number');
     //then
     $this->assertEquals('2343-de', $value);
 }
Exemplo n.º 11
0
 public static function toString()
 {
     return function ($object) {
         return Objects::toString($object);
     };
 }
Exemplo n.º 12
0
 public function _createPdoStatement()
 {
     $sqlString = $this->_humanizedSql . ' with params: ' . Objects::toString($this->_boundValues);
     Logger::getLogger(__CLASS__)->info("Query: %s", array($sqlString));
     return $this->_pdoExecutor->createPDOStatement($this->_dbHandle, $this->_sql, $this->_boundValues, $sqlString);
 }
Exemplo n.º 13
0
 public function get($names, $default = null)
 {
     return Objects::getValueRecursively($this, $names, $default);
 }
Exemplo n.º 14
0
 public function __construct($message, array $errors)
 {
     parent::__construct($message . "\nErrors: " . Objects::toString($errors));
     $this->_errors = $errors;
 }
Exemplo n.º 15
0
function toString($object)
{
    return Objects::toString($object);
}