Decorate a given subject.

@param object $subject

@return object
497988
public function decorate($subject)
    {
        if (is_object($subject)) {
            $subject = clone $subject;
        }

        if ($subject instanceof Model) {
            foreach ($subject->getRelations() as $relationName => $model) {
                $subject->setRelation($relationName, $this->autoPresenter->decorate($model));
            }
        }

        if (!$subject instanceof HasPresenter) {
            return $subject;
        }

        if (!class_exists($presenter = $subject->getPresenterClass())) {
            throw new PresenterNotFoundException($presenter);
        }

        return $this->container->make($presenter)->setWrappedObject($subject);
    }
1291008
protected function getEntityTable($subject)
    {
        if (!isset($this->tableNames[$subject])) {
            $this->tableNames[$subject] = $this->resolveEntityTable($subject);
        }

        return $this->tableNames[$subject];
    }
1092483
public static function ToCamelCase ($subject, $prefix = '_') {
		return Regex::ReplaceCallback(
			"/(?:^|". $prefix .")([a-z])/",
			function ($matches) {return strtoupper($matches[1]);},
			$subject
		);
	}
337320
public function setSubject($subject)
    {
        if ($subject === '') {
            throw new \InvalidArgumentException('$subject must not be empty.', 1331488802);
        }

        if ((strpos($subject, CR) !== false) || (strpos($subject, LF) !== false)) {
            throw new \InvalidArgumentException(
                '$subject must not contain any line breaks or carriage returns.',
                1331488817
            );
        }

        $this->setAsString('subject', $subject);
    }
222014
protected function buildSubject($message)
    {
        if ($this->subject) {
            $message->subject($this->subject);
        } else {
            $message->subject(Str::title(Str::snake(class_basename($this), ' ')));
        }

        return $this;
    }
388317
public function decorate($subject)
    {
        foreach ($subject as $key => $atom) {
            $subject[$key] = $this->autoPresenter->decorate($atom);
        }

        return $subject;
    }
108390
public function createStatemachine($subject)
    {
        $process = $this->processDetector->detectProcess($subject);
        if ($this->stateNameDetector) {
            $stateName = $this->stateNameDetector->detectCurrentStateName($subject);
        } else {
            $stateName = null;
        }
        if ($this->mutexFactory) {
            $mutex = $this->mutexFactory->createMutex($subject);
        } else {
            $mutex = null;
        }

        $statemachine = new Statemachine($subject, $process, $stateName, $this->transitonSelector, $mutex);

        foreach ($this->statemachineObserver as $observer) {
            $statemachine->attach($observer);
        }

        return $statemachine;
    }
62071
public function service( $service, $subject, $predicate = null, $object = null ) {
		$this->graphBuilder->service( $service, $subject, $predicate, $object );
		return $this;
	}
59777
public function initialize($subject, $callback=null)
    {
        $class = is_string($subject) ? ltrim($subject,'\\') : $subject::className();

        // initialize the object if needed
        if (!isset($this->_schema[$class])) {
            $builder = new \Pheasant\SchemaBuilder($this);
            $initializer = $callback ? $callback : $class.'::initialize';

            $this->events()->trigger('beforeInitialize', $builder);
            call_user_func($initializer, $builder, $this);
            $schema = $builder->build($class);

            $this->_schema[$class] = $schema;
            $this->events()->trigger('afterInitialize', $schema);
        }

        return $class;
    }
1195909
public function render(Subject $subject)
    {
        $controller = $this->_controller();
        $controller->viewBuilder()->setClassName('CrudJsonApi.JsonApi');

        // render a JSON API response with resource(s) if data is found
        if (isset($subject->entity) || isset($subject->entities)) {
            return $this->_renderWithResources($subject);
        }

        return $this->_renderWithoutResources();
    }
789900
public function compileSubject(string $subject = null): string
    {
        $settings = Plugin::getInstance()->getSettings();
        return $settings->prependSubject.($settings->prependSubject && $subject ? ' - ' : '').$subject;
    }
460850
public static function first($pattern, $subject, Results\PregObject $object = null): Results\PregObject
    {
        $object = static::pregObject($object);

        $object->result = \preg_match(
            $pattern,
            $subject,
            $object->matches,
            $object->flags,
            $object->offset
        );

        return $object;
    }
171459
private function get_reply_subject($subject) {
        $prefix = get_string('replysubjectprefix', 'tool_messageinbound');
        if (!(substr($subject, 0, strlen($prefix)) == $prefix)) {
            $subject = $prefix . ' ' . $subject;
        }

        return $subject;
    }
1077408
public static function fromObject($object)
    {
        try {
            if (!\is_object($object)) {
                throw new UnexpectedTypeException($object, 'object');
            }

            if ($object instanceof SubjectIdentityInterface) {
                return $object;
            }
            if ($object instanceof SubjectInterface) {
                return new self(ClassUtils::getClass($object), (string) $object->getSubjectIdentifier(), $object);
            }
            if (method_exists($object, 'getId')) {
                return new self(ClassUtils::getClass($object), (string) $object->getId(), $object);
            }
        } catch (InvalidArgumentException $e) {
            throw new InvalidSubjectIdentityException($e->getMessage(), 0, $e);
        }

        throw new InvalidSubjectIdentityException('The object must either implement the SubjectInterface, or have a method named "getId"');
    }
870282
private function decorateResponse(Response $response)
    {
        if ($response instanceof Http\Response) {
            return $response;
        }

        return new Http\Response($response);
    }
608620
public function decorate($subject)
    {
        if (is_object($subject)) {
            $subject = clone $subject;
        }

        if ($subject instanceof Model) {
            foreach ($subject->getRelations() as $relationName => $model) {
                $subject->setRelation($relationName, $this->autoPresenter->decorate($model));
            }
        }

        $presenter = $this->autoPresenterMapper->getPresenter($subject);

        if ($presenter === null) {
            return $subject;
        }

        if (! class_exists($presenter)) {
            throw new PresenterNotFoundException($presenter);
        }

        return $this->container->make($presenter)->setWrappedObject($subject);
    }
173576
public function setSubject($subject)
	{
		$this->getComposer()->subject = $subject;
		$this->getComposer()->subjectCharset = CHARSET;

		return $this;
	}