<?php
class CustomerLocation{
public function checkPhone($phone) {
if(isset($phone) && (strlen($phone) == 10 || strlen($phone) == 12))
{
return $phone;
}
else
{
$aResponse = array(
"error" => "400",
"message" => array(
"code" => "Invalid_phone",
"dev_msg" => "The phone must be at least 10 characters.",
"user_msg" => "Please enter valid phone number."
),
);
return $aResponse;
}
}
}
class test {
public function test()
{
$loc = new CustomerLocation();
$query = array("phone" => $loc->checkPhone('123456'));
// some more code be executed
}
}
I want to return from the test function with the response message written in checkPhone
method of CustomerLocation
class if the phone number does not match the specific condition. But the problem is that I want to check the field of the array which is either by post or request method. How to go about any help will be grateful. Thanks.