public function insertVcode($request) { $json = json_encode($request->parameters); $operators = new Operators(); $jsonObj = json_decode($json); $jsonMessage = $operators->validateJsonForInsertVcode($jsonObj); if ($jsonMessage != Message::SUCCESS) { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => $jsonMessage); $this->outputError($response); return; } if (!$operators->setValuesFromJsonObj($jsonObj)) { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_INVAID_REQUEST_BODY); $this->outputError($response); return; } if (trim($operators->vo_id) == '') { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_VO_ID); $this->outputError($response); return; } if (trim($operators->vo_cf_id) == '') { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_CF_ID); $this->outputError($response); return; } if (trim($operators->vo_operator_id) == '') { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_OPERATOR_ID); $this->outputError($response); return; } if (trim($operators->vo_vcode) == '') { $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_VCODE); $this->outputError($response); return; } $vcodes = $operators->insertVcode($operators); if (!empty($contentFiles)) { $response = array("status" => "SUCCESS-BUSINESS", "status_code" => '200', 'vcodes' => $vcodes); $this->outputSuccess($response); return; } else { $response = array("status" => "ERROR-BUSINESS", "status_code" => '404', 'msgs' => 'No vcode available !.'); $this->outputError($response); return; } }
public function pipeLast() { $arguments = \func_get_args(); $f = \array_shift($arguments); $arguments[] = $this->value; $this->value = Operators::invokeArray($f, $arguments); return $this; }
private static function hashWang($key) { $key = ~$key + ($key << 21); // key = (key << 21) - key - 1; $key = $key ^ Operators::rightShiftZeroFill($key, 24); $key = $key + ($key << 3) + ($key << 8); // key * 265 $key = $key ^ Operators::rightShiftZeroFill($key, 14); $key = $key + ($key << 2) + ($key << 4); // key * 21 $key = $key ^ Operators::rightShiftZeroFill($key, 28); $key = $key + ($key << 31); return $key; }
protected function innerClose() { (new \Yasca\Core\IteratorBuilder())->from($this->pipes)->select(Operators::paramLimit('\\fclose', 1))->where(Operators::curry([Operators::_class, 'equals'], false))->toFunctionPipe()->pipe([Iterators::_class, 'count'])->pipe([Operators::_class, 'match'], [Operators::curry([Operators::_class, 'equals'], 0), Operators::identity(null)], [Operators::identity(true), static function ($failureCount) { throw new \Exception("Unable to close {$failuteCount} process pipes"); }]); if (\is_resource($this->process) === true) { \proc_close($this->process); } }
public function zip(){ $arguments = \func_get_args(); \array_unshift($arguments, $this->iterator); $this->iterator = Operators::invokeArray([Iterators::_class, 'zip'], $arguments); return $this; }
public static function paramLimit(callable $f, $limit){ return static function() use ($f, $limit){ return Operators::invokeArray( $f, (new \Yasca\Core\IteratorBuilder) ->from(\func_get_args()) ->take($limit) ->toArray() ); }; }
public static function __callStatic($name, array $arguments){ return Operators::invokeArray(static::$$name, $arguments); }
, \shell_exec('java -version 2>&1'), $matches )){ return \intval($matches['version']); } else { return 0; } }); static::$isWindows = Operators::lazy(static function(){ return (new \Yasca\Core\FunctionPipe) ->wrap(PHP_OS) ->pipe('\substr', 0, \strlen('win')) ->pipe('\strcasecmp', 'win') ->pipe([Operators::_class, 'equals'], 0) ->unwrap(); }); //TODO: Update with more values where PHP_OS !== 'Linux', but are Linux systems static::$isLinux = Operators::identity(PHP_OS === 'Linux'); static::$isLinuxWithWine = Operators::lazy(static function(){ return static::isLinux() && !preg_match('/no wine in/', \shell_exec('which wine')); }); }, null, __NAMESPACE__ . '\\' . \basename(__FILE__, '.php') )->__invoke();
public function continueWith(callable $asyncFactory) { if ($this->isDone() === true) { return $asyncFactory($this); } $getAsync = Operators::lazy(function () use($asyncFactory) { $async = $asyncFactory($this); while ($async instanceof Wrapper) { $async = $async->unwrap(); } if (!$async instanceof Async) { throw new \UnexpectedValueException('Continuation factory did not return an Async'); } return $async; }); return new self(function () use($getAsync) { return $this->isDone() === true && $getAsync()->isDone() === true; }, function () use($getAsync) { return $getAsync()->result(); }); }
/** * parse un tableau en attribut * * @param array $record */ protected function parse($record) { $this->id = $record['id']; $this->name = $record['name']; $this->type = $record['type']; $this->is_unicity = boolval($record['isUnicity']); $this->is_obligatory = boolval($record['isMandatory']); if (isset($record['valueListId'])) { $this->value_list = $record['valueListId']; } else { $this->value_list = null; } if (isset($record['constraint'])) { $this->constraint = array('value' => $record['constraint']['value'], 'operator' => array('value' => $record['constraint']['operator'], 'string' => Operators::operatorToString($record['constraint']['operator']))); } else { $this->constraint = null; } }