class Car { private $model; private $color; private $year; public function __construct($model, $color, $year) { $this->model = $model; $this->color = $color; $this->year = $year; } public static function createCar($model, $color, $year) { return new self($model, $color, $year); } } $car = Car::createCar('BMW', 'black', 2021);
interface LoggerInterface { public function log($message); } class FileLogger implements LoggerInterface { public function log($message) { // write message to file } } class DbLogger implements LoggerInterface { public function log($message) { // write message to database } } class Logger { public static function createLogger($type) { switch ($type) { case 'file': return new FileLogger(); case 'database': return new DbLogger(); default: throw new InvalidArgumentException('Invalid logger type'); } } } $fileLogger = Logger::createLogger('file'); $fileLogger->log('Hello World');In both examples, we can determine that the package library is not specified as the classes are not part of a specific package or library. They are standalone classes that can be used independently. However, they can be part of a larger package or library for a specific project or application.