本文整理汇总了PHP中ArrayUtils类的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtils类的具体用法?PHP ArrayUtils怎么用?PHP ArrayUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIfItReturnMostRepeatedValueInStringArray
public function testIfItReturnMostRepeatedValueInStringArray()
{
$array = ['Apple', 'Orange', 'Plum', 'Apple', 'Grape', 'Apple'];
$utils = new ArrayUtils();
$mostRepeatedValue = $utils->mostRepeatedValue($array);
$this->assertEquals('Apple', $mostRepeatedValue);
}
示例2: buildDashboard
public function buildDashboard()
{
$this->setDashboardTitle("Stock Dashboard");
$this->setActionPath("/static/transfer/build/tour/motherboard_stock_action.php");
$kpi = new KPIGroupComponent('kpi');
$kpi->setDimensions(12, 2);
$kpi->setCaption('Units stock by Category');
$Units = $this->get_units(true);
foreach ($Units as $key => $value) {
$kpi->addKPI($value['id'], array('caption' => $value['CategoryName'], 'value' => $value['Quantity'], 'numberSuffix' => ' units', 'numberHumanize' => true));
}
$this->addComponent($kpi);
$table = new TableComponent('table');
$table->setCaption("List of Item in Stock");
$table->setDimensions(6, 5);
$stock = $this->get_stock();
$table->addColumn('id', 'Product Id');
$table->addColumn('name', 'Product Name');
$table->addColumn('category', 'Category');
$table->addColumn('price', 'Price', array("numberPrefix" => "\$", "dataType" => "number"));
$table->addColumn('stock', 'Stock');
$table->addMultipleRows($this->PolulateData($stock));
$this->addComponent($table);
$c12 = new FormComponent('filter');
$c12->setDimensions(6, 5);
$c12->setCaption('Filter items in stock');
$category = $this->get_category();
$c12->addSelectField('category', 'Select Category', array_merge(['no selection'], ArrayUtils::pluck($category, 'CategoryName')));
$c12->addTextField('contains', 'Product Name Contains');
$c12->addNumericRangeField('stock', 'Units In Stock', array(0, 100));
$this->addComponent($c12);
$c12->onApplyClick(array($table), 'handleApply', $this);
}
示例3: getCMSFields
function getCMSFields()
{
$fields = new FieldList($rootTab = new TabSet("Root"));
$fields->addFieldsToTab('Root.Main', array(new LiteralField('Break', ColumnFormatter::$left_column_start), new CustomCheckboxSetField('Toolkits', 'What toolkits do you use or plan to use to interact with the OpenStack API?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$toolkits_options, null, array('Other' => 'Other Toolkits (please specify)'))), $t1 = new TextareaField('OtherToolkits', ''), new LiteralField('Break', ColumnFormatter::$right_column_start), new CustomCheckboxSetField('ProgrammingLanguages', 'If you wrote your own code for interacting with the OpenStack API, what programming language did you write it in?', ArrayUtils::AlphaSort(AppDevSurveyOptions::$languages_options, null, array('Other' => 'Other (please specify)'))), $t2 = new TextareaField('OtherProgrammingLanguages', ''), new LiteralField('Break', ColumnFormatter::$end_columns), new LiteralField('Break', ColumnFormatter::$left_column_start), new CustomCheckboxSetField('APIFormats', 'If you wrote your own code for interacting with the OpenStack API, what wire format are you using?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$api_format_options, null, array('Other' => 'Other Wire Format (please specify)'))), $t3 = new TextareaField('OtherAPIFormats', ''), new CustomCheckboxSetField('OperatingSystems', 'What operating systems are you using or plan on using to develop your applications?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$opsys_options, null, array('Other' => 'Other Development OS (please specify)'))), $t4 = new TextareaField('OtherOperatingSystems', ''), new CustomCheckboxSetField('GuestOperatingSystems', 'What guest operating systems are you using or plan on using to deploy your applications to customers?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$opsys_options, null, array('Other' => 'Other Development OS (please specify)'))), $t5 = new TextareaField('OtherGuestOperatingSystems', ''), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Please share your thoughts with us on the state of applications on OpenStack</p>'), new TextAreaField('StruggleDevelopmentDeploying', 'What do you struggle with when developing or deploying applications on OpenStack?'), $docs = new DropdownField('DocsPriority', 'What is your top priority in evaluating API and SDK docs?', AppDevSurveyOptions::$docs_priority_options), $t6 = new TextareaField('OtherDocsPriority', '')));
$docs->setEmptyString('-- Select One --');
return $fields;
}
示例4: __construct
function __construct($controller, $name)
{
// Define fields //////////////////////////////////////
$fields = new FieldList(new LiteralField('paragraph', '<p>
The questions on this page are optional, but will help us better understand the details of how you are using and interacting with OpenStack. Any information you provide on this step will be treated as private and confidential and only used in aggregate reporting.
</p>
<p>
<strong>If you do not wish to answer these questions, you make <a href="' . $controller->Link('SkipAppDevSurvey') . '">skip to the next section</a>.</strong>
</p><hr>'), new CustomCheckboxSetField('Toolkits', 'What toolkits do you use or plan to use to interact with the OpenStack API?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$toolkits_options, null, array('Other' => 'Other Toolkits (please specify)'))), $t1 = new TextareaField('OtherToolkits', ''), new LiteralField('Container', '<div id="wrote_your_own_container" class="hidden">'), $programming_lang = new CustomCheckboxSetField('ProgrammingLanguages', 'If you wrote your own code for interacting with the OpenStack API, what programming language did you write it in?', ArrayUtils::AlphaSort(AppDevSurveyOptions::$languages_options, null, array('Other' => 'Other (please specify)'))), $other_programming_lang = new TextareaField('OtherProgrammingLanguages', ''), new CustomCheckboxSetField('APIFormats', 'If you wrote your own code for interacting with the OpenStack API, what wire format are you using?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$api_format_options, null, array('Other' => 'Other Wire Format (please specify)'))), $t3 = new TextareaField('OtherAPIFormats', ''), new LiteralField('Container', '</div>'), new CustomCheckboxSetField('OperatingSystems', 'What operating systems are you using or plan on using to develop your applications?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$opsys_options, null, array('Other' => 'Other Development OS (please specify)'))), $t4 = new TextareaField('OtherOperatingSystems', ''), new CustomCheckboxSetField('GuestOperatingSystems', 'What guest operating systems are you using or plan on using to deploy your applications to customers?<BR>Select All That Apply', ArrayUtils::AlphaSort(AppDevSurveyOptions::$opsys_options, null, array('Other' => 'Other Development OS (please specify)'))), $t5 = new TextareaField('OtherGuestOperatingSystems', ''), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Please share your thoughts with us on the state of applications on OpenStack</p>'), new TextAreaField('StruggleDevelopmentDeploying', 'What do you struggle with when developing or deploying applications on OpenStack?'), $docs = new DropdownField('DocsPriority', 'What is your top priority in evaluating API and SDK docs?', AppDevSurveyOptions::$docs_priority_options), $t6 = new TextareaField('OtherDocsPriority', ''));
$t1->addExtraClass('hidden');
$t3->addExtraClass('hidden');
$t4->addExtraClass('hidden');
$t5->addExtraClass('hidden');
$t6->addExtraClass('hidden');
$other_programming_lang->addExtraClass('hidden');
$docs->setEmptyString('-- Select One --');
// $prevButton = new CancelFormAction($controller->Link().'Login', 'Previous Step');
$nextButton = new FormAction('SaveAppDevSurvey', ' Next Step ');
$actions = new FieldList($nextButton);
// Create Validators
$validator = new RequiredFields();
Requirements::javascript('surveys/js/deployment_survey_appdevsurvey_form.js');
parent::__construct($controller, $name, $fields, $actions, $validator);
if ($AppDevSurvey = $this->controller->LoadAppDevSurvey()) {
$this->loadDataFrom($AppDevSurvey->data());
}
}
示例5: serializeArray
function serializeArray($result, $instance, $isSimpleResult, $serverKey)
{
$json = "";
if (is_array($result)) {
if (ArrayUtils::isAssociative($result)) {
$json .= "{";
foreach ($result as $key => $value) {
$json .= '"' . $key . '":';
if (is_object($value)) {
$json .= serializeObject($value, $instance, false, $serverKey);
} else {
if (is_array($value)) {
$json .= serializeArray($value, $instance, $isSimpleResult, $serverKey);
} else {
$json .= serializeObject($value, $instance, !is_object($value), $serverKey);
}
}
$json .= ",";
}
} else {
$json .= "[";
for ($i = 0; $i < count($result); $i++) {
$json .= serializeObject($result[$i], $instance, $isSimpleResult, $serverKey) . ",";
}
}
$json = JsonUtils::removeLastChar($result, $json);
if (ArrayUtils::isAssociative($result)) {
$json .= "}";
} else {
$json .= "]";
}
}
return $json;
}
示例6: __construct
function __construct($controller, $name)
{
$org_field = null;
$current_user = Member::currentUser();
$current_affiliations = $current_user->getCurrentAffiliations();
if (!$current_affiliations) {
$org_field = new TextField('Organization', 'Your Organization Name');
} else {
if (count($current_affiliations) > 1) {
$source = array();
foreach ($current_affiliations as $a) {
$org = $a->Organization();
$source[$org->ID] = $org->Name;
}
$source['0'] = "-- New One --";
$ddl = new DropdownField('OrgID', 'Your Organization', $source);
$ddl->setEmptyString('-- Select Your Organization --');
$org_field = new FieldGroup();
$org_field->push($ddl);
$org_field->push($txt = new TextField('Organization', ''));
$txt->addExtraClass('new-org-name');
} else {
$org_field = new TextField('Organization', 'Your Organization Name', $current_user->getOrgName());
}
}
$fields = new FieldList($org_field, new DropdownField('Industry', 'Your Organization’s Primary Industry', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$industry_options, array('' => '-- Please Select One --'), array('Other' => 'Other Industry (please specify)'))), new TextareaField('OtherIndustry', 'Other Industry'), $org_it_activity = new TextareaField('ITActivity', 'Your Organization’s Primary IT Activity'), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Your Organization’s Primary Location or Headquarters</p>'), $country = new DropdownField('PrimaryCountry', 'Country', CountryCodes::$iso_3166_countryCodes), new TextField('PrimaryState', 'State / Province / Region'), new TextField('PrimaryCity', 'City'), new DropdownField('OrgSize', 'Your Organization Size (All Branches, Locations, Sites)', DeploymentSurveyOptions::$organization_size_options), new CustomCheckboxSetField('OpenStackInvolvement', 'What best describes your Organization’s involvement with OpenStack?<BR>Select All That Apply', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$openstack_involvement_options)));
$org_it_activity->addExtraClass('hidden');
$country->setEmptyString('-- Select One --');
$nextButton = new FormAction('NextStep', ' Next Step ');
$actions = new FieldList($nextButton);
$validator = new RequiredFields();
Requirements::javascript('surveys/js/deployment_survey_yourorganization_form.js');
parent::__construct($controller, $name, $fields, $actions, $validator);
}
示例7: __construct
protected function __construct()
{
$this->array = ArrayUtils::instance();
$this->file = FileUtils::instance();
$this->object = ObjectUtils::instance();
$this->string = StringUtils::instance();
}
示例8: isValid
/**
* Defined by Zend\Validator\ValidatorInterface
*
* Returns true if all values validate true
*
* @param mixed $value
* @param mixed $context Additional context
* @return bool
* @throws RuntimeException
*/
public function isValid($value, $context = null)
{
$this->setValue($value);
if ($value instanceof Traversable) {
$value = ArrayUtils::iteratorToArray($value);
}
if (is_array($value)) {
$values = $value;
} elseif (is_string($value)) {
$delimiter = $this->getValueDelimiter();
// Skip explode if delimiter is null,
// used when value is expected to be either an
// array when multiple values and a string for
// single values (ie. MultiCheckbox form behavior)
$values = null !== $delimiter ? explode($this->valueDelimiter, $value) : array($value);
} else {
$values = array($value);
}
$validator = $this->getValidator();
if (!$validator) {
throw new RuntimeException(sprintf('%s expects a validator to be set; none given', __METHOD__));
}
foreach ($values as $value) {
// provide context to validators isValid method
if (!$validator->isValid($value, $context)) {
$this->abstractOptions['messages'][] = $validator->getMessages();
if ($this->isBreakOnFirstFailure()) {
return false;
}
}
}
return count($this->abstractOptions['messages']) == 0;
}
示例9: getCMSFields
function getCMSFields()
{
$CountryCodes = CountryCodes::$iso_3166_countryCodes;
$CountryCodes['Worldwide'] = 'Worldwide';
$CountryCodes['Prefer not to say'] = 'Prefer not to say';
$CountryCodes['Too many to list'] = 'Too many to list';
$fields = new FieldList($rootTab = new TabSet("Root"));
$fields->addFieldsToTab('Root.Main', array(new LiteralField('Break', '<p>Each deployment profile can be marked public if you wish for the basic information on this page to appear on openstack.org. If you select private we will treat all of the profile information as confidential information.</p>'), new OptionSetField('IsPublic', 'Would you like to keep this information confidential or allow the Foundation to share information about this deployment publicly?', array('1' => '<strong>Willing to share:</strong> The information on this page may be shared for this deployment', '0' => '<strong>Confidential:</strong> All details provided should be kept confidential to the OpenStack Foundation'), 0), new LiteralField('Break', '<hr/>'), new TextField('Label', 'Deployment Name<BR><p class="clean_text">Please create a friendly label, like “Production OpenStack Deployment”. This name is for your deployment in our survey tool. If several people at your organization work on one deployment, we would <b>really appreciate</b> you all referring to the same deployment by the same name!</p>'), $ddl_stage = new DropdownField('DeploymentStage', 'In what stage is your OpenStack deployment? (make a new deployment profile for each type of deployment)', DeploymentOptions::$stage_options), new MultiDropdownField('CountriesPhysicalLocation', 'In which country / countries is this OpenStack deployment physically located?', $CountryCodes), new MultiDropdownField('CountriesUsersLocation', 'In which country / countries are the users / customers for this deployment physically located?', $CountryCodes), $ddl_type = new DropdownField('DeploymentType', 'Deployment Type', DeploymentOptions::$deployment_type_options), new CustomCheckboxSetField('ProjectsUsed', 'Projects Used', DeploymentOptions::$projects_used_options), new CustomCheckboxSetField('CurrentReleases', 'What releases are you currently using?', DeploymentOptions::$current_release_options), new LiteralField('Break', 'Describe the workloads and frameworks running in this OpenStack environment.<BR>Select All That Apply'), new LiteralField('Break', '<hr/>'), new CustomCheckboxSetField('ServicesDeploymentsWorkloads', '<b>Services Deployments - workloads designed to be accessible for external users / customers</b>', DeploymentOptions::$services_deployment_workloads_options), $other_service_workload = new TextAreaField('OtherServicesDeploymentsWorkloads', ''), new CustomCheckboxSetField('EnterpriseDeploymentsWorkloads', '<b>Enterprise Deployments - workloads designed to be run internally to support business</b>', DeploymentOptions::$enterprise_deployment_workloads_options), $other_enterprise_workload = new TextAreaField('OtherEnterpriseDeploymentsWorkloads', ''), new CustomCheckboxSetField('HorizontalWorkloadFrameworks', '<b>Horizontal Workload Frameworks</b>', DeploymentOptions::$horizontal_workload_framework_options), $other_horizontal_workload = new TextAreaField('OtherHorizontalWorkloadFrameworks', '')));
$ddl_type->setEmptyString('-- Select One --');
$ddl_stage->setEmptyString('-- Select One --');
$details = array(new LiteralField('Break', '<p>The information below will help us better understand the most common configuration and component choices OpenStack deployments are using.</p>'), new LiteralField('Break', '<h3>Telemetry</h3>'), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Please provide the following information about the size and scale of this OpenStack deployment. This information is optional, but will be kept confidential and <b>never</b> published in connection with you or your organization.</p>'), new DropdownField('OperatingSystems', 'What is the main operating system running this OpenStack cloud deployment?', ArrayUtils::AlphaSort(DeploymentOptions::$operating_systems_options, array('' => '-- Select One --'), array('Other' => 'Other (please specify)'))), $other_os = new TextareaField('OtherOperatingSystems', ''), new CustomCheckboxSetField('UsedPackages', 'What packages does this deployment use…?<BR>Select All That Apply', DeploymentOptions::$used_packages_options), new CustomCheckboxSetField('CustomPackagesReason', 'If you have modified packages or have built your own packages, why?<BR>Select All That Apply', DeploymentOptions::$custom_package_reason_options), $other_custom_reason = new TextareaField('OtherCustomPackagesReason', ''), new CustomCheckboxSetField('DeploymentTools', 'What tools are you using to deploy / configure this cluster?<BR>Select All That Apply', DeploymentOptions::$deployment_tools_options), $other_deployment_tools = new TextareaField('OtherDeploymentTools', ''), new CustomCheckboxSetField('PaasTools', 'What Platform-as-a-Service (PaaS) tools are you using to manage applications on this OpenStack deployment?', ArrayUtils::AlphaSort(DeploymentOptions::$paas_tools_options, array('' => '-- Select One --'), array('Other' => 'Other Tool (please specify)'))), $other_paas = new TextareaField('OtherPaasTools', ''), new CustomCheckboxSetField('Hypervisors', 'If this deployment uses <b>OpenStack Compute (Nova)</b>, which hypervisors are you using?<BR>Select All That Apply', DeploymentOptions::$hypervisors_options), new TextareaField('OtherHypervisor', ''), new CustomCheckboxSetField('SupportedFeatures', 'Which compatibility APIs does this deployment support?<BR> Select All That Apply', DeploymentOptions::$deployment_features_options), new TextareaField('OtherSupportedFeatures', ''), new CustomCheckboxSetField('UsedDBForOpenStackComponents', 'What database do you use for the components of this OpenStack cloud?<BR>Select All That Apply', DeploymentOptions::$used_db_for_openstack_components_options), new TextareaField('OtherUsedDBForOpenStackComponents', ''), new CustomCheckboxSetField('NetworkDrivers', ' If this deployment uses <b>OpenStack Network (Neutron)</b>, which drivers are you using?<BR>Select All That Apply', DeploymentOptions::$network_driver_options), new TextareaField('OtherNetworkDriver', ''), new CustomCheckboxSetField('IdentityDrivers', 'If you are using <b>OpenStack Identity Service (Keystone)</b> which OpenStack identity drivers are you using?<BR>Select All That Apply', DeploymentOptions::$identity_driver_options), new TextareaField('OtherIndentityDriver', ''), new CustomCheckboxSetField('BlockStorageDrivers', 'If this deployment uses <b>OpenStack Block Storage (Cinder)</b>, which drivers are <BR>Select All That Apply', DeploymentOptions::$block_storage_divers_options), new TextareaField('OtherBlockStorageDriver', ''), new CustomCheckboxSetField('InteractingClouds', 'With what other clouds does this OpenStack deployment interact?<BR>Select All That Apply', DeploymentOptions::$interacting_clouds_options), new TextareaField('OtherInteractingClouds', ''), $ddl_users = new DropdownField('NumCloudUsers', 'Number of users', DeploymentOptions::$cloud_users_options), $ddl_nodes = new DropdownField('ComputeNodes', 'Physical compute nodes', DeploymentOptions::$compute_nodes_options), $ddl_cores = new DropdownField('ComputeCores', 'Processor cores', DeploymentOptions::$compute_cores_options), $ddl_instances = new DropdownField('ComputeInstances', 'Number of instances', DeploymentOptions::$compute_instances_options), $ddl_ips = new DropdownField('NetworkNumIPs', 'Number of fixed / floating IPs', DeploymentOptions::$network_ip_options), $ddl_block_size = new DropdownField('BlockStorageTotalSize', 'If this deployment uses <b>OpenStack Block Storage (Cinder)</b>, what is the size of its block storage?', DeploymentOptions::$storage_size_options), $ddl_block_size = new DropdownField('ObjectStorageSize', 'If this deployment uses <b>OpenStack Object Storage (Swift)</b>, what is the size of its block storage?', DeploymentOptions::$storage_size_options), $ddl_objects_size = new DropdownField('ObjectStorageNumObjects', 'If this deployment uses <b>OpenStack Object Storage (Swift)</b>, how many total objects are stored?', DeploymentOptions::$storage_objects_options), new LiteralField('Break', '<h3>Spotlight</h3>'), new LiteralField('Break', '<hr/>'), new CustomCheckboxSetField('WhyNovaNetwork', 'If this deployment uses nova-network and not OpenStack Network (Neutron), what would allow you to migrate to Neutron?', DeploymentOptions::$why_nova_network_options), $other_why_nova = new TextareaField('OtherWhyNovaNetwork', ''), $ddl_swift_dist_feat = new DropdownField('SwiftGlobalDistributionFeatures', 'Are you using Swift\'s global distribution features?', DeploymentOptions::$swift_global_distribution_features_options), $ddl_uses_cases = new DropdownField('SwiftGlobalDistributionFeaturesUsesCases', 'If yes, what is your use case?', DeploymentOptions::$swift_global_distribution_features_uses_cases_options), $other_uses_cases = new TextareaField('OtherSwiftGlobalDistributionFeaturesUsesCases', ''), $ddl_policies = new DropdownField('Plans2UseSwiftStoragePolicies', 'Do you have plans to use Swift\'s storage policies or erasure codes in the next year?', DeploymentOptions::$plans_2_use_swift_storage_policies_options), new TextareaField('OtherPlans2UseSwiftStoragePolicies', ''), $ddl_other_tools = new DropdownField('ToolsUsedForYourUsers', 'What tools are you using charging or show-back for your users?', DeploymentOptions::$tools_used_for_your_users_options), $other_tools = new TextareaField('OtherToolsUsedForYourUsers', ''), new TextareaField('Reason2Move2Ceilometer', 'If you are not using Ceilometer, what would allow you to move to it (optional free text)?'));
$ddl_users->setEmptyString('-- Select One --');
$ddl_nodes->setEmptyString('-- Select One --');
$ddl_cores->setEmptyString('-- Select One --');
$ddl_instances->setEmptyString('-- Select One --');
$ddl_ips->setEmptyString('-- Select One --');
$ddl_block_size->setEmptyString('-- Select One --');
$ddl_block_size->setEmptyString('-- Select One --');
$ddl_objects_size->setEmptyString('-- Select One --');
$ddl_swift_dist_feat->setEmptyString('-- Select One --');
$ddl_uses_cases->setEmptyString('-- Select One --');
$ddl_policies->setEmptyString('-- Select One --');
$ddl_other_tools->setEmptyString('-- Select One --');
$fields->addFieldsToTab('Root.Details', $details);
return $fields;
}
示例10: createService
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
*
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('config');
if ($config instanceof Traversable) {
$config = ArrayUtils::iteratorToArray($config);
}
return new TwitterInfoService($config['twitter']['cache_path']);
}
示例11: testIsAssociative
function testIsAssociative()
{
$this->assertFalse(ArrayUtils::isAssociative(null));
$this->assertFalse(ArrayUtils::isAssociative(array()));
$this->assertFalse(ArrayUtils::isAssociative(array(1, 2, 3)));
$this->assertFalse(ArrayUtils::isAssociative(array("value", 2, false)));
$this->assertTrue(ArrayUtils::isAssociative(array("key1" => "value1", "key2" => "value2")));
}
示例12: expand
/**
* Expands flat array to multi-dimensional associative array
* using keys names as paths.
*
* @param array $flatten
*
* @return array
*/
public static function expand(array $flatten)
{
$nested = array();
foreach ($flatten as $path => $value) {
ArrayUtils::set($nested, $path, $value);
}
return $nested;
}
示例13: testFlatten
/**
* Test for Schwaen\Stdlib\ArrayUtils::flatten
*/
public function testFlatten()
{
$arr1 = ['name' => 'Sven', 'Name' => 'Max'];
$arr2 = ['a', [['b']], ['c'], [[[['d']]]]];
$this->assertEquals($arr1, ArrayUtils::flatten($arr1, true));
$this->assertEquals(['Sven', 'Max'], ArrayUtils::flatten($arr1, false));
$this->assertEquals(['a', 'b', 'c', 'd'], ArrayUtils::flatten($arr2));
}
示例14: currency_to_symbol
static function currency_to_symbol($currency)
{
if (ArrayUtils::contains_key($currency, self::$currency_symbols)) {
return self::$currency_symbols[$currency];
} else {
throw new InvalidParameterException("Valuta non supportata!!");
}
}
示例15: set
public static function set($key, $value)
{
if (!self::exists($key)) {
$set = ArrayUtils::stringToNestedArray($key, $value);
self::$config = ArrayUtils::merge(self::$config, $set);
}
return false;
}