_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q263100 | Order.generateUniqueHash | test | public function generateUniqueHash()
{
return md5(sprintf("%s.%s.%s.%s.%s.%s.%s",
$this->getCustomerId(),
$this->getCountryIso(),
$this->getCityId(),
$this->getCityPrefix(),
$this->getMapData()->getMapDetail(),
$this->getAutorenewEnable(),
date("YmdHis")
));
} | php | {
"resource": ""
} |
q263101 | ApiCredentials.generateAuthString | test | protected function generateAuthString()
{
if (empty($this->password) || empty($this->userName)) {
throw new ApiCredentialsException(" Undefined userName and/or password ");
}
$this->authString = $this->getTestMode() ? sha1($this->userName . $this->password . 'sandbox') : sha1($this->userName . $this->password);
} | php | {
"resource": ""
} |
q263102 | CDRInvoice.load | test | public function load()
{
$response = $this->call('callhistory_invoices', array(
'customer_id' => $this->getCustomerId(),
'from_date' => $this->getFromDate(),
'to_date' => $this->getToDate()
));
$this->fromArray($response);
return $this;
} | php | {
"resource": ""
} |
q263103 | ApiClient.call | test | public function call($method, $arguments = array())
{
$arguments = array_merge(array('auth_string' => self::getCredentials()->getAuthString()), $arguments);
$method = 'didww_' . $method;
$timeStart = microtime(true);
try {
$result = $this->_client->__soapCall($method, $arguments);
} catch (\Exception $e) {
if (self::$_debug) {
$this->debug("raw request", $this->_client->__getLastRequest());
$this->debug("raw response", $this->_client->__getLastResponse());
}
throw $e;
}
if (self::$_debug) {
$this->debug("raw request", $this->_client->__getLastRequest());
$this->debug("raw response", $this->_client->__getLastResponse());
}
/**
* check if api returned error and throw exception
*/
if (isset($result->error) && $result->error > 0) {
$message = isset (self::$_errorCodes[$result->error]) ? self::$_errorCodes[$result->error] :
'Unknown error with code : ' . $result->error;
throw new ApiClientException($message);
}
$timeFinish = microtime(true);
$this->time = $timeFinish - $timeStart;
if (self::$_debug) {
$this->debug("response from $method:", $result);
}
return (array)$result;
} | php | {
"resource": ""
} |
q263104 | Decoded.getFrame | test | public function getFrame($index = 0)
{
if (array_key_exists($index, $this->frames)) {
return $this->frames[$index];
}
throw new RuntimeException(
"Frame with index ({$index}) does not exists."
);
} | php | {
"resource": ""
} |
q263105 | Decoded.addOffset | test | public function addOffset($left, $top)
{
$offset = new \StdClass;
$offset->left = $left;
$offset->top = $top;
$this->addToFirstFrameWithoutProperty($offset, 'offset');
} | php | {
"resource": ""
} |
q263106 | Decoded.addSize | test | public function addSize($width, $height)
{
$size = new \StdClass;
$size->width = $width;
$size->height = $height;
$this->addToFirstFrameWithoutProperty($size, 'size');
} | php | {
"resource": ""
} |
q263107 | Decoded.getLoops | test | public function getLoops()
{
if ($this->netscapeExtension) {
$loops = substr($this->netscapeExtension, 14, 2);
$loops = unpack('C', $loops)[1];
return $loops;
}
return null;
} | php | {
"resource": ""
} |
q263108 | Decoded.hasGlobalColorTable | test | public function hasGlobalColorTable()
{
$byte = substr($this->logicalScreenDescriptor, 4, 1);
if (strlen($byte) == 1) {
$byte = unpack('C', $byte)[1];
$bit = $byte & bindec('10000000');
}
return isset($bit) ? (bool) $bit : false;
} | php | {
"resource": ""
} |
q263109 | Decoded.countGlobalColors | test | public function countGlobalColors()
{
$byte = substr($this->logicalScreenDescriptor, 4, 1);
if (strlen($byte) == 1) {
$byte = unpack('C', $byte)[1];
$bit = $byte & bindec('00000111');
}
// length of the global color table is 2^(N+1)
return isset($bit) ? pow(2, $bit + 1) : 0;
} | php | {
"resource": ""
} |
q263110 | Decoded.getBackgroundColorIndex | test | public function getBackgroundColorIndex()
{
if ($this->logicalScreenDescriptor) {
$index = substr($this->logicalScreenDescriptor, 5, 1);
$index = unpack('C', $index)[1];
return $index;
}
return 0;
} | php | {
"resource": ""
} |
q263111 | Decoded.addToFirstFrameWithoutProperty | test | private function addToFirstFrameWithoutProperty($value, $property)
{
$added = false;
foreach ($this->frames as $key => $frame) {
if ( ! $frame->propertyIsSet($property)) {
$frame->setProperty($property, $value);
$added = true;
break;
}
}
if ( ! $added) {
$this->newFrameWithProperty($property, $value);
}
return $added;
} | php | {
"resource": ""
} |
q263112 | Decoded.newFrameWithProperty | test | private function newFrameWithProperty($property, $value)
{
$frame = new Frame;
$this->frames[] = $frame->setProperty($property, $value);
} | php | {
"resource": ""
} |
q263113 | Object.toArray | test | public function toArray($options = array())
{
$result = array();
foreach (get_object_vars($this) as $key => $value) {
if ($key[0] == '_') {
continue;
}
if ($value instanceof Object) {
$value = $value->toArray($options);
}
$result[\Didww\Utils\StringUtil::snakeCase($key)] = $value;
}
return $result;
} | php | {
"resource": ""
} |
q263114 | Balance._getAllBalances | test | protected static function _getAllBalances()
{
$result = self::getClientInstance()->call('getprepaidbalancelist', array(
"customer_id" => '0'
));
$resellerSubAccount = (object)array('customer_id' => '0', 'prepaid_balance_amount' => '0.0000'); // 0 - is reseller's sub account
array_unshift($result, $resellerSubAccount);
return $result;
} | php | {
"resource": ""
} |
q263115 | Balance.getBalanceArray | test | public static function getBalanceArray()
{
$balances = array();
foreach (self::_getAllBalances() as $value) {
$balances[$value->customer_id] = $value->prepaid_balance_amount;
}
return $balances;
} | php | {
"resource": ""
} |
q263116 | Balance.getBalanceList | test | public static function getBalanceList()
{
$balances = array();
foreach (self::_getAllBalances() as $value) {
$value = (array)$value;
unset($value['result']);
unset($value['error']);
$balance = new Balance(array("prepaid_balance" => $value['prepaid_balance_amount'], "customer_id" => $value["customer_id"]));
$balances[$value['customer_id']] = $balance;
}
return $balances;
} | php | {
"resource": ""
} |
q263117 | Balance.changeBalance | test | function changeBalance($funds, $transactionId = NULL)
{
if (!$this->getCustomerId() > 0) {
throw new BalanceException("Customer is invalid");
}
if (!(is_numeric($funds))) {
throw new BalanceException("Funds value is invalid");
}
$this->_funds = $funds;
$this->_transactionId = ($transactionId ? $transactionId : $this->generateTransactionId());
if (!is_string($this->_transactionId) || strlen($this->_transactionId) != 32) {
throw new BalanceException(" TransactionId value is invalid");
}
$response = $this->call('updateprepaidbalance', array(
"customer_id" => $this->getCustomerId(),
"prepaid_funds" => $this->_funds,
"operation_type" => ($this->_funds > 0) ? self::OP_ADD : self::OP_REMOVE,
"uniq_hash" => $this->_transactionId
));
//set prepaid balance value
$this->setPrepaidBalance($response['prepaid_balance']);
return $this;
} | php | {
"resource": ""
} |
q263118 | Balance.synchronizePrepaidBalance | test | function synchronizePrepaidBalance()
{
if (!$this->getCustomerId()) {
throw new BalanceException("Customer Id is undefined");
}
$response = $this->call('getprepaidbalance', array(
"customer_id" => $this->getCustomerId()
));
$this->setPrepaidBalance($response['prepaid_balance']);
return $this;
} | php | {
"resource": ""
} |
q263119 | Encoder.setCanvas | test | public function setCanvas($width, $height)
{
$this->canvasWidth = $width;
$this->canvasHeight = $height;
return $this;
} | php | {
"resource": ""
} |
q263120 | Encoder.setFromDecoded | test | public function setFromDecoded(Decoded $decoded, $frameIndex = null)
{
if (is_null($frameIndex)) {
// setup from all decoded data
$width = $decoded->getCanvasWidth();
$height = $decoded->getCanvasHeight();
$colorTable = $decoded->getGlobalColorTable();
$loops = $decoded->getLoops();
$frames = $decoded->getFrames();
} else {
// setup only one specific frame
$frame = $decoded->getFrame($frameIndex);
$frame->setOffset(0, 0);
$width = $frame->decodeWidth();
$height = $frame->decodeHeight();
$colorTable = $frame->hasLocalColorTable() ? $frame->getLocalColorTable() : $decoded->getGlobalColorTable();
$loops = 0;
$frames = array($frame);
}
// setup
$this->setCanvas($width, $height);
$this->setGlobalColorTable($colorTable);
$this->setBackgroundColorIndex($decoded->getBackgroundColorIndex());
$this->setLoops($loops);
$this->setFrames($frames);
return $this;
} | php | {
"resource": ""
} |
q263121 | Encoder.createFrameFromGdResource | test | public function createFrameFromGdResource($resource, $delay = null)
{
// get imagedata from resource
$gifdata = $this->encodeGdResource($resource);
$decoder = new Decoder;
$gif = $decoder->initFromData($gifdata)->decode();
$frame = $gif->getFrames()[0];
$frame->setLocalColorTable($gif->getGlobalColorTable());
$frame->setDelay($delay);
$this->frames[] = $frame;
} | php | {
"resource": ""
} |
q263122 | Encoder.encode | test | public function encode()
{
// create gif
$encoded = $this->buildLogicalScreenDescriptor();
if ($this->hasGlobalColorTable()) {
$encoded .= $this->getGlobalColorTable();
}
// netscape extension
if ($this->isAnimated() && $this->doesLoop()) {
$encoded .= $this->buildNetscapeExtension();
}
// add frame(s)
foreach ($this->frames as $frame) {
$encoded .= $this->buildFrame($frame);
}
// EOF
$encoded .= "\x3B";
return $encoded;
} | php | {
"resource": ""
} |
q263123 | Encoder.buildLogicalScreenDescriptor | test | private function buildLogicalScreenDescriptor()
{
// gif header
$descriptor = 'GIF89a';
// canvas width/height
$descriptor .= pack('v*', $this->canvasWidth);
$descriptor .= pack('v*', $this->canvasHeight);
// packed field
$colorResolution = 111;
$sortFlag = 0;
if ($this->hasGlobalColorTable()) {
$globalColorTableFlag = 1;
$globalColorTableSize = log(strlen($this->getGlobalColorTable()) / 3, 2) - 1;
$globalColorTableSize = decbin($globalColorTableSize);
$globalColorTableSize = str_pad($globalColorTableSize, 3, 0, STR_PAD_LEFT);
} else {
$globalColorTableFlag = 0;
$globalColorTableSize = 0;
}
$packed = $globalColorTableFlag.$colorResolution.$sortFlag.$globalColorTableSize;
$descriptor .= pack('C', bindec($packed));
// background color index
$descriptor .= pack('C', $this->backgroundColorIndex);
// pixel aspect ratio
$descriptor .= "\x00";
return $descriptor;
} | php | {
"resource": ""
} |
q263124 | Encoder.buildNetscapeExtension | test | private function buildNetscapeExtension()
{
$extension = "\x21";
$extension .= "\xFF";
$extension .= "\x0B";
$extension .= 'NETSCAPE2.0';
$extension .= "\x03";
$extension .= "\x01";
$extension .= pack('v', $this->loops);
$extension .= "\x00";
return $extension;
} | php | {
"resource": ""
} |
q263125 | Encoder.buildFrame | test | private function buildFrame(Frame $frame)
{
// graphics control extensions
$encoded = $this->buildGraphicsControlExtension($frame);
// image descriptor
$encoded .= $this->buildImageDescriptor($frame);
// add image data
$encoded .= $frame->getImageData();
return $encoded;
} | php | {
"resource": ""
} |
q263126 | Encoder.buildGraphicsControlExtension | test | private function buildGraphicsControlExtension(Frame $frame)
{
// start
$extension = "\x21\xF9";
// byte size
$extension .= "\x04";
// packed field
$disposalMethod = decbin($frame->getDisposalMethod());
$disposalMethod = str_pad($disposalMethod, 3, 0, STR_PAD_LEFT);
$userInputFlat = 0;
$transparentColorFlag = $frame->hasTransparentColor() ? 1 : 0;
$packed = $disposalMethod.$userInputFlat.$transparentColorFlag;
$packed = str_pad($packed, 3, 0, STR_PAD_LEFT);
$extension .= pack('C', bindec($packed));
// delay
$extension .= pack('v*', $frame->getDelay());
// transparent color index
if ($frame->hasTransparentColor()) {
$extension .= $frame->getTransparentColorIndex();
} else {
$extension .= "\x00";
}
// block terminator
$extension .= "\x00";
return $extension;
} | php | {
"resource": ""
} |
q263127 | Encoder.buildImageDescriptor | test | private function buildImageDescriptor(Frame $frame)
{
// seperator
$descriptor = "\x2C";
// image left/top
$descriptor .= pack('v*',
$frame->offset->left,
$frame->offset->top
);
// image width/height
$descriptor .= pack('v*',
$frame->size->width,
$frame->size->height
);
$interlacedFlag = $frame->isInterlaced() ? 1 : 0;
$reserved1 = 0;
$reserved2 = 0;
if ($frame->hasLocalColorTable()) {
$colorTableFlag = 1;
$colorTableSize = log(strlen($frame->getLocalColorTable()) / 3, 2) - 1;
$colorTableSize = decbin($colorTableSize);
$sortFlag = 0;
} else {
$colorTableFlag = 0;
$colorTableSize = 0;
$sortFlag = 0;
}
$colorTableSize = str_pad($colorTableSize, 3, 0, STR_PAD_LEFT);
// packed field
$packed = $colorTableFlag.$interlacedFlag.$sortFlag.$reserved1.$reserved2.$colorTableSize;
$descriptor .= pack('C', bindec($packed));
if ($frame->hasLocalColorTable()) {
// add local color table
$descriptor .= $frame->getLocalColorTable();
}
return $descriptor;
} | php | {
"resource": ""
} |
q263128 | DIDNumber.create | test | public static function create(Order $order)
{
$properties = self::getClientInstance()->call('ordercreate', $order->toArray(array('includeNumber' => false)));
$did = new DIDNumber($order);
$did->getOrder()->setCityId($properties['city_id']);
unset($properties['result'], $properties['autorenew_enable'], $properties['city_prefix'], $properties['country_iso'], $properties['country_iso'], $properties['city_id']);
$did->fromArray($properties);
return $did;
} | php | {
"resource": ""
} |
q263129 | DIDNumber.changeAutorenew | test | function changeAutorenew($flag)
{
$this->call('order_autorenew_status', array(
"customer_id" => $this->_order->getCustomerId(),
"did_number" => $this->getDIDNumber(),
"status" => (int)$flag
));
$this->_order->setAutorenewEnable($flag);
} | php | {
"resource": ""
} |
q263130 | DIDNumber.renew | test | public function renew()
{
$properties = $this->call('orderautorenew', array(
"customer_id" => $this->_order->getCustomerId(),
"did_number" => $this->getDIDNumber(),
"period" => $this->_order->getPeriod(),
"uniq_hash" => $this->generateUniqueHash()
));
$this->getOrder()->setCityId($properties['city_id']);
unset($properties['result'], $properties['autorenew_enable'], $properties['city_prefix'], $properties['country_iso'], $properties['city_id']);
unset($properties['result'], $properties['autorenew_enable']);
$this->fromArray($properties);
return $this;
} | php | {
"resource": ""
} |
q263131 | DIDNumber._reload | test | protected function _reload($didNumber = NULL, $orderId = NULL)
{
$properties = $this->call('getservicedetails', array(
"customer_id" => $this->_order->getCustomerId(),
"order_id" => $orderId,
"did_number" => $didNumber
));
unset($properties['result']);
$this->fromServiceData($properties);
} | php | {
"resource": ""
} |
q263132 | DIDNumber.updateMapping | test | public function updateMapping(Mapping $newMapping = NULL)
{
$mapping = empty($newMapping) ? $this->_order->getMapData() : $newMapping;
$this->call('updatemapping', array(
"customer_id" => $this->_order->getCustomerId(),
"did_number" => $this->getDIDNumber(),
"map_data" => $mapping->toArray()
));
$this->_order->setMapData($newMapping);
return true;
} | php | {
"resource": ""
} |
q263133 | DIDNumber.generateUniqueHash | test | protected function generateUniqueHash()
{
return $this->_order->getUniqHash() ?:
md5(sprintf("%s.%s.%s.%s.%s.%s",
$this->getDIDExpireDateGmt(),
$this->getOrderId(),
$this->getDIDMappingFormat(),
$this->getDIDPeriod(),
$this->getDIDTimeLeft(),
$this->getDIDNumber()
));
} | php | {
"resource": ""
} |
q263134 | AbstractOrigin.isIpInRange | test | protected function isIpInRange($targetIp, $rangeIp, $cidrMask)
{
$target = sprintf('%032b', ip2long($targetIp));
$range = sprintf('%032b', ip2long($rangeIp));
return 0 === substr_compare($target, $range, 0, $cidrMask);
} | php | {
"resource": ""
} |
q263135 | Container.getParameter | test | public function getParameter(string $name, $default = null)
{
return $this->hasParameter($name) ? $this->parameters[$name] : $default;
} | php | {
"resource": ""
} |
q263136 | Container.linkMetaService | test | private function linkMetaService(string $serviceName, string $key)
{
// make sure the service link is there
if (!isset($this->metadataService[$serviceName])) {
$this->metadataService[$serviceName] = [];
}
if (!in_array($key, $this->metadataService[$serviceName])) {
$this->metadataService[$serviceName][] = $key;
}
} | php | {
"resource": ""
} |
q263137 | Container.setMetaData | test | public function setMetaData(string $serviceName, string $key, array $values)
{
// make sure the service exists
if (!$this->has($serviceName)) {
throw new UnknownServiceException('There is no service named "' . $serviceName . '" specified.');
}
// make sure all elements are arrays
foreach($values as $value)
{
if (!is_array($value)) {
throw new ContainerException('Every meta data value must be an array. "' . gettype($value) . '" given.');
}
}
// make sure the metadata key is allocated
if (!isset($this->metadata[$key])) {
$this->metadata[$key] = [];
}
// write
$this->metadata[$key][$serviceName] = $values;
$this->linkMetaService($serviceName, $key);
} | php | {
"resource": ""
} |
q263138 | Container.addMetaData | test | public function addMetaData(string $serviceName, string $key, array $values)
{
// make sure the service exists
if (!$this->has($serviceName)) {
throw new UnknownServiceException('There is no service named "' . $serviceName . '" specified.');
}
// make sure the metadata key is allocated
if (!isset($this->metadata[$key])) {
$this->metadata[$key] = [];
}
// make sure the service key is allocated
if (!isset($this->metadata[$key][$serviceName])) {
$this->metadata[$key][$serviceName] = [];
}
// append
$this->metadata[$key][$serviceName][] = $values;
$this->linkMetaService($serviceName, $key);
} | php | {
"resource": ""
} |
q263139 | Container.remove | test | public function remove(string $serviceName) : bool
{
if (!$this->has($serviceName)) {
return false; // can only remove services that exist
}
if ($serviceName === 'container') {
return false; // the container itself cannot be removed
}
// remove the already shared instnace if set
if (isset($this->resolvedSharedServices[$serviceName])) {
unset($this->resolvedSharedServices[$serviceName]);
}
// remove the service type
if (isset($this->serviceResolverType[$serviceName])) {
unset($this->serviceResolverType[$serviceName]);
}
// remove all possible references
if (isset($this->serviceProviders[$serviceName])) {
unset($this->serviceProviders[$serviceName]);
}
if (isset($this->resolverMethods[$serviceName])) {
unset($this->resolverMethods[$serviceName]);
}
if (isset($this->resolverFactories[$serviceName])) {
unset($this->resolverFactories[$serviceName]);
}
return true;
} | php | {
"resource": ""
} |
q263140 | Container.release | test | public function release(string $serviceName) : bool
{
if (isset($this->resolvedSharedServices[$serviceName]))
{
unset($this->resolvedSharedServices[$serviceName]); return true;
}
return false;
} | php | {
"resource": ""
} |
q263141 | Container.get | test | public function get(string $serviceName)
{
// if the service container itself is requested
if ($serviceName === 'container') {
return $this;
}
// check if the service name has a registered service type
if (!isset($this->serviceResolverType[$serviceName]))
{
throw new UnknownServiceException('Could not find service named "' . $serviceName . '" registered in the container.');
}
$serviceResolverType = $this->serviceResolverType[$serviceName];
// check if a service instance already exists
if (
isset($this->resolvedSharedServices[$serviceName]) &&
$serviceResolverType !== static::RESOLVE_FACTORY
) {
return $this->resolvedSharedServices[$serviceName];
}
switch ($serviceResolverType)
{
// Default resolver for all services that are defined
// directly in the container. We can skip here an unnecessary method call.
case static::RESOLVE_METHOD:
return $this->{$this->resolverMethods[$serviceName]}();
break;
case static::RESOLVE_PROVIDER:
return $this->resolveServiceProvider($serviceName);
break;
case static::RESOLVE_FACTORY:
return $this->resolveServiceFactory($serviceName);
break;
case static::RESOLVE_SHARED:
return $this->resolveServiceShared($serviceName);
break;
default:
throw new UnknownServiceException('Could not resolve service named "' . $serviceName . '", the resolver type is unkown.');
break;
}
} | php | {
"resource": ""
} |
q263142 | Container.createInstanceFromFactory | test | private function createInstanceFromFactory($factory)
{
if ($factory instanceof ServiceFactoryInterface)
{
return $factory->create($this);
}
elseif ($factory instanceof Closure)
{
return $factory($this);
}
// otherwise throw an exception
throw new InvalidServiceException('Service could not be resolved, the registered factory is invalid.');
} | php | {
"resource": ""
} |
q263143 | Container.resolveServiceProvider | test | private function resolveServiceProvider(string $name)
{
list($service, $isShared) = $this->serviceProviders[$name]->resolve($name, $this);
if ($isShared) {
$this->resolvedSharedServices[$name] = $service;
}
return $service;
} | php | {
"resource": ""
} |
q263144 | Container.register | test | public function register(ServiceProviderInterface $provider)
{
foreach($provider->provides() as $serviceName)
{
$this->setServiceResolverType($serviceName, static::RESOLVE_PROVIDER);
$this->serviceProviders[$serviceName] = $provider;
}
} | php | {
"resource": ""
} |
q263145 | Container.bind | test | public function bind(string $name, $factory, bool $shared = true)
{
if (is_string($factory)) {
return $this->bindClass($name, $factory, [], $shared);
} elseif ($shared) {
$this->bindFactoryShared($name, $factory);
} else {
$this->bindFactory($name, $factory);
}
} | php | {
"resource": ""
} |
q263146 | Container.bindClass | test | public function bindClass(string $name, string $factory, array $arguments = [], bool $shared = true) : ServiceFactory
{
$factory = new ServiceFactory($factory, $arguments);
if ($shared) {
$this->bindFactoryShared($name, $factory);
} else {
$this->bindFactory($name, $factory);
}
return $factory;
} | php | {
"resource": ""
} |
q263147 | Container.bindFactory | test | public function bindFactory(string $name, $factory)
{
$this->setServiceResolverType($name, static::RESOLVE_FACTORY);
$this->resolverFactories[$name] = $factory;
} | php | {
"resource": ""
} |
q263148 | Container.bindFactoryShared | test | public function bindFactoryShared(string $name, $factory)
{
$this->setServiceResolverType($name, static::RESOLVE_SHARED);
$this->resolverFactories[$name] = $factory;
} | php | {
"resource": ""
} |
q263149 | Container.getServiceResolverType | test | public function getServiceResolverType(string $serviceName) : int
{
if (!isset($this->serviceResolverType[$serviceName]))
{
throw new UnknownServiceException('There is no type for the service named "' . $serviceName . '" specified.');
}
return $this->serviceResolverType[$serviceName];
} | php | {
"resource": ""
} |
q263150 | ServiceArguments.addArgument | test | private function addArgument($argumentValue, int $argumentType) : ServiceArguments
{
$this->arguments[] = [$argumentValue, $argumentType]; return $this;
} | php | {
"resource": ""
} |
q263151 | ServiceArguments.addArgumentsFromArray | test | public function addArgumentsFromArray(array $argumentsArray)
{
foreach($argumentsArray as $argument)
{
if (is_string($argument) && ($argument[0] === '@' || $argument[0] === ':'))
{
if ($argument[0] === '@') {
$this->addDependency(substr($argument, 1));
} elseif ($argument[0] === ':') {
$this->addParameter(substr($argument, 1));
}
} else {
$this->addRaw($argument);
}
}
} | php | {
"resource": ""
} |
q263152 | ServiceArguments.resolve | test | public function resolve(Container $container) : array
{
$resolvedArguments = [];
foreach($this->arguments as list($argumentValue, $argumentType))
{
switch ($argumentType)
{
case static::RAW:
$resolvedArguments[] = $argumentValue;
break;
case static::DEPENDENCY:
$resolvedArguments[] = $container->get($argumentValue);
break;
case static::PARAMETER:
$resolvedArguments[] = $container->getParameter($argumentValue);
break;
}
}
return $resolvedArguments;
} | php | {
"resource": ""
} |
q263153 | ServiceFactory.create | test | public function create(Container $container)
{
$instance = new $this->className(...$this->constructorArguments->resolve($container));
foreach($this->methodCallers as list($method, $arguments))
{
$instance->{$method}(... $arguments->resolve($container));
}
return $instance;
} | php | {
"resource": ""
} |
q263154 | ContainerParser.setTokens | test | public function setTokens(array $tokens)
{
// reset the keys
$this->tokens = array_values($tokens);
// count the real number of tokens
$this->tokenCount = count($this->tokens);
// reset the index
$this->index = 0;
} | php | {
"resource": ""
} |
q263155 | ContainerParser.currentToken | test | protected function currentToken() : T
{
if (!isset($this->tokens[$this->index]))
{
throw new ContainerParserException("The current token is of the available tokens range.");
}
return $this->tokens[$this->index];
} | php | {
"resource": ""
} |
q263156 | ContainerParser.nextToken | test | protected function nextToken(int $i = 1)
{
if (!isset($this->tokens[$this->index + $i])) {
return false;
}
return $this->tokens[$this->index + $i];
} | php | {
"resource": ""
} |
q263157 | ContainerParser.skipTokenOfType | test | protected function skipTokenOfType(array $types = [])
{
while ((!$this->parserIsDone()) && in_array($this->currentToken()->getType(), $types))
{
$this->skipToken();
}
} | php | {
"resource": ""
} |
q263158 | ContainerParser.getRemainingTokens | test | protected function getRemainingTokens(bool $skip = false) : array
{
$tokens = array();
while (!$this->parserIsDone())
{
$tokens[] = $this->currentToken(); $this->skipToken();
}
if (!$skip)
{
$this->index -= count($tokens);
}
return $tokens;
} | php | {
"resource": ""
} |
q263159 | ContainerParser.getTokensUntil | test | protected function getTokensUntil(int $type, bool $ignoreScopes = false) : array
{
$tokens = array();
if (!is_array($type)) {
$type = array($type);
}
while (!$this->parserIsDone() && !in_array($this->currentToken()->getType(), $type))
{
// if scopes should be ignored, we need to check if the current
// token opens one an then get all tokens inside the scope
if ($ignoreScopes && $this->currentToken()->isType(T::TOKEN_SCOPE_OPEN))
{
foreach($this->getTokensUntilClosingScope(true, T::TOKEN_SCOPE_OPEN, T::TOKEN_SCOPE_CLOSE) as $token) {
$tokens[] = $token;
}
} else {
$tokens[] = $this->currentToken();
$this->skipToken();
}
}
return $tokens;
} | php | {
"resource": ""
} |
q263160 | ContainerParser.getTokensUntilClosingScope | test | protected function getTokensUntilClosingScope(bool $includeScope = false, int $openToken = T::TOKEN_BRACE_OPEN, int $closeToken = T::TOKEN_BRACE_CLOSE) : array
{
if ($this->currentToken()->getType() !== $openToken)
{
throw $this->errorUnexpectedToken($this->currentToken());
}
$tokens = array();
// include the opening scope
if ($includeScope) {
$tokens[] = $this->currentToken();
}
$this->skipToken();
$currentLevel = 0;
while($this->currentToken() && !($this->currentToken()->getType() === $closeToken && $currentLevel === 0))
{
if ($this->currentToken()->getType() === $openToken)
{
$currentLevel++;
}
if ($this->currentToken()->getType() === $closeToken)
{
$currentLevel--;
}
$tokens[] = $this->currentToken();
$this->skipToken();
}
// include the closing scope
if ($includeScope) {
$tokens[] = $this->currentToken();
}
// skip the closing scope
$this->skipToken();
return $tokens;
} | php | {
"resource": ""
} |
q263161 | ContainerParser.errorUnexpectedToken | test | protected function errorUnexpectedToken($token)
{
$class = new \ReflectionClass($token);
$constants = array_flip($class->getConstants());
return new ContainerParserException('unexpected "' . $constants[$token->getType()] . '" given at line ' . $token->getLine());
} | php | {
"resource": ""
} |
q263162 | ContainerParser.parseChild | test | protected function parseChild(string $parserClassName, $tokens = null, $skip = true)
{
if (is_null($tokens))
{
$tokens = $this->getRemainingTokens();
}
$parser = new $parserClassName($tokens);
$node = $parser->parse();
// Update the current index based on the work of the child parser.
if ($skip)
{
$this->skipToken($parser->getParsedTokensCount());
}
// finally return the parsed node
return $node;
} | php | {
"resource": ""
} |
q263163 | ContainerParser.parse | test | public function parse()
{
// reset the result
$this->result = array();
// start parsing trought the tokens
while (!$this->parserIsDone())
{
$specialNode = $this->next();
if ($specialNode instanceof Node)
{
return $specialNode;
}
}
// return the result after the loop is done
return $this->node();
} | php | {
"resource": ""
} |
q263164 | ContainerBuilder.setContainerName | test | public function setContainerName(string $containerName)
{
if (empty($containerName) || !(preg_match('/^[a-zA-Z0-9\\\\_]*$/', $containerName)) || is_numeric($containerName[0]))
{
throw new ContainerBuilderException('The container name cannot be empty, start with a number or contain sepcial characters except "\\".');
}
if ($containerName[0] === "\\")
{
$containerName = substr($containerName, 1);
}
$this->containerClassName = $this->containerName = $containerName;
// check if we need to generate a namespace
if (($pos = strrpos($containerName, "\\")) !== false)
{
$this->containerNamespace = substr($containerName, 0, $pos);
$this->containerClassName = substr($containerName, $pos + 1);
}
} | php | {
"resource": ""
} |
q263165 | ContainerBuilder.add | test | public function add(string $serviceName, string $serviceClass, array $serviceArguments = [], bool $isShared = true) : ServiceDefinition
{
$service = new ServiceDefinition($serviceClass, $serviceArguments);
$this->addService($serviceName, $service, $isShared);
return $service;
} | php | {
"resource": ""
} |
q263166 | ContainerBuilder.addArray | test | public function addArray(array $servicesArray)
{
foreach($servicesArray as $serviceName => $serviceConfiguration)
{
$this->addService($serviceName, ServiceDefinition::fromArray($serviceConfiguration), $serviceConfiguration['shared'] ?? true);
}
} | php | {
"resource": ""
} |
q263167 | ContainerBuilder.addService | test | public function addService(string $serviceName, ServiceDefinitionInterface $serviceDefinition, bool $isShared = true)
{
if ($this->invalidServiceBuilderString($serviceName))
{
throw new ContainerBuilderException('The "'.$serviceName.'" servicename must be a string, cannot be numeric, empty or contain any special characters except "." and "_".');
}
// add the service definition
$this->services[$serviceName] = $serviceDefinition;
// generate the normalized name
$this->generateNormalizedServiceName($serviceName);
// set the shared unshared flag
if ($isShared && (!in_array($serviceName, $this->shared)))
{
$this->shared[] = $serviceName;
}
elseif ((!$isShared) && in_array($serviceName, $this->shared))
{
unset($this->shared[array_search($serviceName, $this->shared)]);
}
} | php | {
"resource": ""
} |
q263168 | ContainerBuilder.importNamespace | test | public function importNamespace(ContainerNamespace $namespace)
{
// import the parameters
$this->parameters = array_merge($this->parameters, $namespace->getParameters());
// import the service definitions
foreach($namespace->getServices() as $name => $service)
{
$this->addService($name, $service);
}
} | php | {
"resource": ""
} |
q263169 | ContainerBuilder.invalidServiceBuilderString | test | private function invalidServiceBuilderString(string $value) : bool
{
if (empty($value) || is_numeric($value)) {
return true;
}
// check for trailing / prepending whitespace ect.
if (trim($value) !== $value) {
return true;
}
// check for other special characters
if (preg_match('/[^a-zA-Z0-9._]+/', $value)) {
return true;
}
// also check the first character the string contains with a number
if (is_numeric($value[0]) || $value[0] === '.' || $value[0] === '_') {
return true;
}
$lastCharacter = $value[strlen($value) - 1];
if ($lastCharacter === '.' || $lastCharacter === '_') {
return true;
}
return false;
} | php | {
"resource": ""
} |
q263170 | ContainerBuilder.generateNormalizedServiceName | test | private function generateNormalizedServiceName(string $serviceName)
{
$normalizedServiceName = $this->camelizeServiceName($serviceName);
$duplicateCounter = 0;
$countedNormalizedServiceName = $normalizedServiceName;
while(in_array($countedNormalizedServiceName, $this->normalizedServiceNames))
{
$duplicateCounter++;
$countedNormalizedServiceName = $normalizedServiceName . $duplicateCounter;
}
$this->normalizedServiceNames[$serviceName] = $countedNormalizedServiceName;
} | php | {
"resource": ""
} |
q263171 | ContainerBuilder.generate | test | public function generate() : string
{
$buffer = "<?php\n\n";
// add namespace if needed
if (!is_null($this->containerNamespace))
{
$buffer .= "namespace " . $this->containerNamespace . ";\n\n";
}
// add use statement for the super container
$aliasContainerName = 'ClanCatsContainer' . md5($this->containerName);
$buffer .= "use " . Container::class . " as " . $aliasContainerName . ";\n\n";
// generate the the class
$buffer .= "class $this->containerClassName extends $aliasContainerName {\n\n";
$buffer .= $this->generateParameters() . "\n";
$buffer .= $this->generateMetaData() . "\n";
$buffer .= $this->generateResolverTypes() . "\n";
$buffer .= $this->generateResolverMappings() . "\n";
$buffer .= $this->generateResolverMethods() . "\n";
return $buffer . "\n}";
} | php | {
"resource": ""
} |
q263172 | ContainerBuilder.getResolverMethodName | test | private function getResolverMethodName(string $serviceName) : string
{
if (!isset($this->normalizedServiceNames[$serviceName]))
{
throw new ContainerBuilderException("The '" . $serviceName . "' service has never been definied.");
}
return 'resolve' . $this->normalizedServiceNames[$serviceName];
} | php | {
"resource": ""
} |
q263173 | ContainerBuilder.generateArgumentsCode | test | private function generateArgumentsCode(ServiceArguments $arguments) : string
{
$buffer = [];
foreach($arguments->getAll() as list($argumentValue, $argumentType))
{
if ($argumentType === ServiceArguments::DEPENDENCY)
{
if ($argumentValue === 'container')
{
$buffer[] = "\$this";
}
// if the dependency is defined in the current container builder
// we can be sure that it exists and directly call the resolver method
elseif (isset($this->services[$argumentValue]))
{
$resolverMethodCall = "\$this->" . $this->getResolverMethodName($argumentValue) . '()';
// if is not shared we can just forward the factory method
if (!in_array($argumentValue, $this->shared))
{
$buffer[] = $resolverMethodCall;
}
// otherwise we have to check if the singleton has
// already been resolved.
else
{
$buffer[] = "\$this->resolvedSharedServices['$argumentValue'] ?? \$this->resolvedSharedServices['$argumentValue'] = " . $resolverMethodCall;
}
}
// if the dependency is not defined inside the container builder
// it might be added dynamically later. So we just access the containers `get` method.
else
{
$buffer[] = "\$this->get('$argumentValue')";
}
}
elseif ($argumentType === ServiceArguments::PARAMETER)
{
$buffer[] = "\$this->getParameter('$argumentValue')";
}
elseif ($argumentType === ServiceArguments::RAW)
{
$buffer[] = var_export($argumentValue, true);
}
}
return implode(', ', $buffer);
} | php | {
"resource": ""
} |
q263174 | ContainerBuilder.generateMetaData | test | private function generateMetaData() : string
{
$metaData = [];
$metaDataService = [];
foreach($this->services as $serviceName => $serviceDefinition)
{
foreach($serviceDefinition->getMetaData() as $key => $serviceMetaData)
{
if (!isset($metaData[$key])) {
$metaData[$key] = [];
}
$metaData[$key][$serviceName] = $serviceMetaData;
// mapping for the service centered
if (!isset($metaDataService[$serviceName])) {
$metaDataService[$serviceName] = [];
}
if (!in_array($key, $metaDataService[$serviceName])) {
$metaDataService[$serviceName][] = $key;
}
}
}
return "protected \$metadata = " . var_export($metaData, true) . ";\nprotected \$metadataService = " . var_export($metaDataService, true) . ";\n";
} | php | {
"resource": ""
} |
q263175 | ContainerBuilder.generateResolverTypes | test | private function generateResolverTypes() : string
{
$types = [];
foreach($this->services as $serviceName => $serviceDefinition)
{
$types[] = var_export($serviceName, true) . ' => ' . Container::RESOLVE_METHOD;
}
return "protected \$serviceResolverType = [" . implode(', ', $types) . "];\n";
} | php | {
"resource": ""
} |
q263176 | ContainerBuilder.generateResolverMappings | test | private function generateResolverMappings() : string
{
$mappings = [];
foreach($this->services as $serviceName => $serviceDefinition)
{
$mappings[] = var_export($serviceName, true) . ' => ' . var_export($this->getResolverMethodName($serviceName), true);
}
return "protected \$resolverMethods = [" . implode(', ', $mappings) . "];\n";
} | php | {
"resource": ""
} |
q263177 | ContainerBuilder.generateResolverMethods | test | private function generateResolverMethods() : string
{
$buffer = "";
foreach($this->services as $serviceName => $serviceDefinition)
{
$buffer .= "protected function " . $this->getResolverMethodName($serviceName) . "() {\n";
$serviceClassName = $serviceDefinition->getClassName();
if ($serviceClassName[0] !== "\\")
{
$serviceClassName = "\\" . $serviceClassName;
}
$buffer .= "\t\$instance = new " . $serviceClassName . "(". $this->generateArgumentsCode($serviceDefinition->getArguments()) .");\n";
foreach($serviceDefinition->getMethodCalls() as list($callName, $callArguments))
{
$buffer .= "\t\$instance->" . $callName . '('. $this->generateArgumentsCode($callArguments) .");\n";
}
if (in_array($serviceName, $this->shared))
{
$buffer .= "\t\$this->resolvedSharedServices[" . var_export($serviceName, true) . "] = \$instance;\n";
}
$buffer .= "\treturn \$instance;\n";
$buffer .= "}\n";
}
return $buffer;
} | php | {
"resource": ""
} |
q263178 | ValueNode.fromToken | test | public static function fromToken(Token $token) : ValueNode
{
if (!$token->isValue())
{
throw new LogicalNodeException('Can only create ValueNode from a value type Token.');
}
return new ValueNode($token->getValue(), $token->getType());
} | php | {
"resource": ""
} |
q263179 | ValueNode.setType | test | public function setType(int $type)
{
if (!in_array($type, [
self::TYPE_STRING,
self::TYPE_NUMBER,
self::TYPE_BOOL_TRUE,
self::TYPE_BOOL_FALSE,
self::TYPE_NULL,
]))
{
throw new LogicalNodeException('Invalid value type assigned.');
}
$this->type = $type;
} | php | {
"resource": ""
} |
q263180 | ComposerContainerFileLoader.generateMap | test | public static function generateMap(Event $event)
{
// prepare the container file mapping array
$mapping = [];
// get all available packages
$packages = $event->getComposer()->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
foreach ($packages as $package)
{
if ($package instanceof CompletePackage)
{
$extra = $package->getExtra();
if (isset($extra['container']) && !empty($extra['container']))
{
foreach($extra['container'] as $containerImportName => $containerFileName)
{
// special case for the main file
if ($containerImportName === '@main') {
$containerImportName = $package->getName();
} else {
$containerImportName = $package->getName() . '/' . $containerImportName;
}
$event->getIO()->write('found <fg=blue>'. $containerImportName .'</>', true, ConsoleIO::VERBOSE);
// also prefix the container file with package name
$containerFileName = $package->getName() . '/' . $containerFileName;
// assign the mapping
$mapping[$containerImportName] = '__DIR__' . $containerFileName;
}
}
}
}
$mappingFilePath = $event->getComposer()->getConfig()->get('vendor-dir') . '/container_map.php';
// define the mapping file
$mappingFileHeader = "<?php\n\$vendorDir = __DIR__ . '/';\n\nreturn ";
$mappingFileContent = str_replace('\'__DIR__', '$vendorDir . \'', var_export($mapping, true));
// store it
file_put_contents($mappingFilePath, $mappingFileHeader . $mappingFileContent . ';');
$event->getIO()->write("<fg=green>Generated container map file</>");
} | php | {
"resource": ""
} |
q263181 | Token.getValue | test | public function getValue()
{
$value = $this->value;
switch ($this->type)
{
case self::TOKEN_BOOL_TRUE:
$value = true;
break;
case self::TOKEN_BOOL_FALSE:
$value = false;
break;
case self::TOKEN_STRING:
$value = str_replace("\\", "", substr($value, 1, -1));
break;
case self::TOKEN_NUMBER:
$value = $value + 0;
break;
case self::TOKEN_NULL:
$value = null;
break;
}
return $value;
} | php | {
"resource": ""
} |
q263182 | Token.isValue | test | public function isValue() : bool
{
return
$this->type === self::TOKEN_STRING ||
$this->type === self::TOKEN_NUMBER ||
$this->type === self::TOKEN_NULL ||
$this->type === self::TOKEN_BOOL_TRUE ||
$this->type === self::TOKEN_BOOL_FALSE;
} | php | {
"resource": ""
} |
q263183 | ArrayNode.has | test | public function has($key)
{
foreach ($this->elements as $element) {
if ($element->getKey() == $key) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q263184 | ArrayNode.push | test | public function push(AssignableNode $value)
{
// count the index up to find a free spot
while ($this->has($this->index)) {
$this->index++;
}
$this->addElement(new ArrayElementNode($this->index, $value));
} | php | {
"resource": ""
} |
q263185 | ArrayNode.convertToNativeArray | test | public function convertToNativeArray() : array
{
$array = [];
foreach($this->getElements() as $element)
{
$value = $element->getValue();
if ($value instanceof ValueNode) {
$array[$element->getKey()] = $value->getRawValue();
}
elseif ($value instanceof ArrayNode) {
$array[$element->getKey()] = $value->convertToNativeArray();
}
else {
throw new LogicalNodeException("You cannot convert a ctn array to PHP that contains a reference to a service or parameter.");
}
}
return $array;
} | php | {
"resource": ""
} |
q263186 | ContainerLexer.next | test | protected function next()
{
if ($this->offset >= $this->length)
{
return false;
}
foreach ($this->tokenMap as $regex => $token)
{
if (preg_match($regex, substr($this->code, $this->offset), $matches))
{
if ($token === T::TOKEN_LINE) {
$this->line++;
}
$this->offset += strlen($matches[0]);
return new T($this->line + 1, $token, $matches[0]);
}
}
throw new ContainerLexerException(sprintf('Unexpected character "%s" on line %s', $this->code[$this->offset], $this->line));
} | php | {
"resource": ""
} |
q263187 | ContainerLexer.tokens | test | public function tokens() : array
{
$tokens = [];
while ($token = $this->next())
{
// skip doublicated linebreaks
if (
$token->getType() === T::TOKEN_LINE &&
isset($tokens[count($tokens) - 1]) &&
$tokens[count($tokens) - 1]->getType() === T::TOKEN_LINE
) {
continue;
}
$tokens[] = $token;
}
return $tokens;
} | php | {
"resource": ""
} |
q263188 | DeployController.index | test | public function index()
{
// set up logging to email
$this->log = Log::getMonolog();
if ($to = config('auto-deploy.notify')) {
$domain = parse_url(config('app.url'), PHP_URL_HOST);
$msg = \Swift_Message::newInstance('Project Deployed')
->setFrom(["do_not_reply@$domain" => "Laravel Auto-Deploy[$domain]"])
->setTo($to)
->setBody('', 'text/html');
$handler = new SwiftMailerHandler(Mail::getSwiftMailer(), $msg, Logger::NOTICE);
$handler->setFormatter(new HtmlFormatter());
$this->log->pushHandler($handler);
}
// check to see if we should execute this event
if (in_array($this->origin->event(), array_keys(config("auto-deploy.{$this->origin->name}")))) {
// get the parameters for the event we're handling
$configKey = "auto-deploy.{$this->origin->name}.{$this->origin->event()}";
$this->webroot = config("$configKey.webroot");
$this->installDir = dirname($this->webroot).'/'.date('Y-m-d').'_'.$this->commitId;
$steps = config("$configKey.steps");
// execute the configured steps
$this->result = [
'Commit_ID' => $this->commitId,
'Timestamp' => date('r'),
'output' => '',
];
$whitelist = ['backupDatabase','pull','copyEnv','composer','npm','migrate','seed','deploy'];
foreach ($steps as $step) {
if (in_array($step, $whitelist) && !$this->{$step}()) {
$this->log->error('Deploy failed.', $this->result);
return;
}
}
$this->log->notice('Deploy succeeded!', $this->result);
} else {
$this->log->error('Deploy failed.', ['Reason' => 'This event was not configured.']);
}
} | php | {
"resource": ""
} |
q263189 | DeployController.ex | test | private function ex(CommandInterface $cmd)
{
// try to run the command
$this->shell->run($cmd);
$output = $this->shell->getOutput();
$returnValue = $this->shell->getReturnValue();
// record the result
$output = count($output) ? implode("\n", $output)."\n" : '';
$this->result['output'] .= "$cmd\n$output";
// return a boolean
return 0 === $returnValue;
} | php | {
"resource": ""
} |
q263190 | DeployController.backupDatabase | test | private function backupDatabase()
{
// get the name of the DB to backed up and the connection to use
$dbdir = database_path();
$dbconn = config('database.default');
$dbname = config("database.connections.$dbconn.database");
// make a directory for the backup file and switch into that directory
$cmd = new Command('cd');
$cmd->addParam($dbdir)
->addSubCommand('&&')
->addSubCommand('mkdir')
->addParam('backups');
if ($this->ex($cmd)) {
$cmd = new Command('cd');
$cmd->addParam($dbdir.'/backups')
->addSubCommand('&&');
switch ($dbconn) {
case 'sqlite':
$cmd->addSubCommand('cp');
$cmd->addParam($dbname)
->addParam('.');
return $this->ex($cmd);
case 'mysql':
$cmd->addSubCommand('mysqldump');
$cmd->addParam($dbname)
->addParam('>')
->addParam("$dbname.sql");
return $this->ex($cmd);
case 'pgsql':
$cmd->addSubCommand('pg_dump');
$cmd->addParam($dbname)
->addParam('>')
->addParam("$dbname.sql");
return $this->ex($cmd);
}
}
return false;
} | php | {
"resource": ""
} |
q263191 | DeployController.pull | test | private function pull()
{
if (is_writable(dirname($this->installDir))) {
$cmd = new Command('mkdir');
$cmd->addFlag('p')
->addParam($this->installDir);
if ($this->ex($cmd)) {
$cmd = new Command('cd');
$cmd->addParam($this->installDir)
->addSubCommand('&&')
->addSubCommand('git')
->addSubCommand('clone')
->addParam($this->repoUrl)
->addParam('.');
return $this->ex($cmd);
}
}
return false;
} | php | {
"resource": ""
} |
q263192 | DeployController.copyEnv | test | private function copyEnv()
{
$cmd = new Command('cp');
$cmd->addParam($this->webroot.'./env')
->addParam($this->installDir.'/.env');
return $this->ex($cmd);
} | php | {
"resource": ""
} |
q263193 | DeployController.composer | test | private function composer()
{
$cmd = new Command('cd');
$cmd->addParam($this->installDir)
->addSubCommand('&&')
->addSubCommand('composer')
->addParam('self-update')
->addSubCommand('&&')
->addSubCommand('composer')
->addParam('update')
->addArgument('no-interaction');
return $this->ex($cmd);
} | php | {
"resource": ""
} |
q263194 | DeployController.npm | test | private function npm()
{
$cmd = new Command('cd');
$cmd->addParam($this->installDir)
->addSubCommand('&&')
->addSubCommand('npm')
->addParam('update');
return $this->ex($cmd);
} | php | {
"resource": ""
} |
q263195 | DeployController.seed | test | private function seed()
{
$cmd = new Command('cd');
$cmd->addParam($this->installDir)
->addSubCommand('&&')
->addSubCommand('php')
->addSubCommand('artisan')
->addParam('db:seed');
return $this->ex($cmd);
} | php | {
"resource": ""
} |
q263196 | DeployController.deploy | test | private function deploy()
{
$cmd = new Command('cd');
$cmd->addParam(dirname($this->webroot))
->addSubCommand('&&')
->addSubCommand('ln')
->addFlag('fs')
->addParam($this->installDir)
->addParam($this->webroot);
return $this->ex($cmd);
} | php | {
"resource": ""
} |
q263197 | ServiceProviderArray.resolve | test | public function resolve(string $serviceName, Container $container) : array
{
if (!isset($this->services[$serviceName]))
{
throw new UnknownServiceException('The service provider "' . get_class($this) . '" does not support service resolving of the service "' . $serviceName . '"');
}
$serviceConfiguration = $this->services[$serviceName];
// create the factory
$factory = ServiceFactory::fromArray($serviceConfiguration);
// resolve the service
$service = $factory->create($container);
// if the service is not shared skip the store
if ((!isset($serviceConfiguration['shared'])) || $serviceConfiguration['shared'] !== false)
{
return [$service, true];
}
return [$service, false];
} | php | {
"resource": ""
} |
q263198 | ContainerFactory.setCacheDirecotry | test | public function setCacheDirecotry(string $cacheDirectory)
{
if (substr($cacheDirectory, -1) !== DIRECTORY_SEPARATOR)
{
$cacheDirectory .= DIRECTORY_SEPARATOR;
}
$this->cacheDirectory = $cacheDirectory;
} | php | {
"resource": ""
} |
q263199 | ContainerFactory.create | test | public function create(string $containerName, callable $builderCallback, array $initalParameters = []) : Container
{
if (class_exists($containerName))
{
return new $containerName;
}
$fileName = basename(str_replace("\\", '/', $containerName));
$cacheFile = $this->cacheDirectory . $fileName . '.php';
if ((!(file_exists($cacheFile) && is_readable($cacheFile))) || $this->isDebugMode())
{
$builder = new ContainerBuilder($containerName);
// run the builder callback
$builderCallback($builder);
// store the cache file
$cacheDir = dirname($cacheFile);
if (!is_dir($cacheDir) || !is_writable($cacheDir)) {
throw new ContainerException("The directory \"{$cacheDir}\" is not writable. Cannot generate container class.");
} elseif (is_file($cacheFile) && !is_writable($cacheFile)) {
throw new ContainerException("The file \"{$cacheFile}\" is not writable. Cannot generate container class.");
}
file_put_contents($cacheFile, $builder->generate());
}
// require the generated cache file
require_once $cacheFile;
// create an instance of the generated container
return new $containerName($initalParameters);
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.